From 89027634384e68e3b85b95c30e6be36cf36434ed Mon Sep 17 00:00:00 2001 From: Amin <69254513+AminGh05@users.noreply.github.com> Date: Sun, 29 Jun 2025 23:27:03 +0330 Subject: [PATCH] Update Session08 Backend.md upsert person endpoints --- .../Session08/Session08 Backend.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ProjectOrientedSessions/Session08/Session08 Backend.md b/ProjectOrientedSessions/Session08/Session08 Backend.md index 6321118..c882a9f 100644 --- a/ProjectOrientedSessions/Session08/Session08 Backend.md +++ b/ProjectOrientedSessions/Session08/Session08 Backend.md @@ -334,6 +334,47 @@ public async Task> UpsertPersonAsync(long accountId, PersonDto dto) return Result.Success(person.Id); } ``` +``` +[HttpPost("account-person")] +public async Task UpsertAccountPerson([FromBody] PersonDto dto) +{ + long accountId = _userContext.GetUserId(); + if (accountId <= 0) + { + return Unauthorized(); + } + + var result = await _personService.UpsertAccountPersonAsync(accountId, dto); + return result.Status switch + { + ResultStatus.Success => NoContent(), + ResultStatus.Unauthorized => Unauthorized(result.ErrorMessage), + ResultStatus.NotFound => NotFound(result.ErrorMessage), + ResultStatus.ValidationError => BadRequest(result.ErrorMessage), + _ => StatusCode(500, result.ErrorMessage) + }; +} + +[HttpPost("person")] +public async Task UpsertPerson([FromBody] PersonDto dto) +{ + long accountId = _userContext.GetUserId(); + if (accountId <= 0) + { + return Unauthorized(); + } + + var result = await _personService.UpsertPersonAsync(accountId, dto); + return result.Status switch + { + ResultStatus.Success => NoContent(), + ResultStatus.Unauthorized => Unauthorized(result.ErrorMessage), + ResultStatus.NotFound => NotFound(result.ErrorMessage), + ResultStatus.ValidationError => BadRequest(result.ErrorMessage), + _ => StatusCode(500, result.ErrorMessage) + }; +} +``` ## ✅ My Travels Tab