Пример #1
0
        public async Task <Reservation> Create(Reservation Reservation)
        {
            if (!await ReservationValidator.Create(Reservation))
            {
                return(Reservation);
            }

            try
            {
                await UOW.Begin();

                await UOW.ReservationRepository.Create(Reservation);

                await UOW.Commit();

                await Logging.CreateAuditLog(Reservation, new { }, nameof(ReservationService));

                return(await UOW.ReservationRepository.Get(Reservation.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await Logging.CreateSystemLog(ex.InnerException, nameof(ReservationService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }