Exemple #1
0
        public async Task <GuestResponse> DeleteAsync(int id)
        {
            var existingGuest = await _guestRepository.FindByIdAsync(id);

            if (existingGuest == null)
            {
                return(new GuestResponse("Guest not found"));
            }

            try
            {
                _guestRepository.Remove(existingGuest);
                await _unitOfWork.CompleteAsync();

                return(new GuestResponse(existingGuest));
            }
            catch (Exception e)
            {
                //TODO - Log the exception
                return(new GuestResponse("An error ocurred while deleting the Guest: " +
                                         $"{ e.Message } { e.InnerException?.Message }"));
            }
        }