Exemplo n.º 1
0
        public async Task <IActionResult> Update([FromBody] Guest guestIn)
        {
            try
            {
                var guest = await _guestService.GetByGuestIn(guestIn._id);

                if (guest == null)
                {
                    return(NotFound("Guest not found"));
                }

                guest.participate = guestIn.participate;
                guest.plusOne     = guestIn.plusOne;
                guest.plusOneName = guestIn.plusOneName;

                // checking plus one
                if (guestIn.participate == "no" || guestIn.plusOne == false)
                {
                    guest.plusOne     = false;
                    guest.plusOneName = "";
                }

                await _guestService.Update(guestIn._id, guest);

                var guestList = await _guestService.Get();

                return(Ok(guestList));
            }
            catch (System.Exception)
            {
                return(StatusCode(500));
            }
        }