public async Task <Guest> UpdateGuest(GuestForEditDto updatedGuestDto) { var guest = await _guestRepo.GetFirstOrDefault(g => g.Id == updatedGuestDto.Id); if (guest == null) { throw new System.ArgumentException("Unable to update guest", string.Empty); } _mapper.Map(updatedGuestDto, guest); await _guestRepo.SaveAsync(); return(guest); }
public async Task <IActionResult> UpdateGuest([FromBody] GuestForEditDto updatedGuestDto) { var currentUserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); if (currentUserId == 0) { return(Unauthorized()); } try { await _guestStayService.UpdateGuest(updatedGuestDto); } catch (ArgumentException e) { ModelState.AddModelError("Exception", e.Message); return(BadRequest(ModelState)); } return(Ok()); }