Пример #1
0
        public async Task <ServiceResponse <BookingInfo> > CancelAsync(string bookingNumber, string email)
        {
            Log.Information("BookingService processing request for CancelAsync {@request}", bookingNumber);

            var booking = await repo.GetByBookingNumberAsync(bookingNumber);

            if (booking == null)
            {
                return(new ServiceResponse <BookingInfo>("Could not find any booking with given BookingNumber"));
            }
            if (booking.Email != email)
            {
                return(new ServiceResponse <BookingInfo>("Email does not match Booking"));
            }

            try
            {
                booking.Cancel();
                await repo.Complete();

                return(new ServiceResponse <BookingInfo>(booking.ToDto()));
            }
            catch (Exception ex) { return(new ServiceResponse <BookingInfo>($"Failure canceling Booking: {ex.Message}")); }
        }