예제 #1
0
        public async Task <Contracts.Models.Booking> BookAsync(int accommodationId, Contracts.Models.BookingDetails details)
        {
            var accommodation = await facilityDataSource.FindAccommodationAsync(accommodationId);

            if (accommodation == null)
            {
                throw new AccommodationNotFoundException(accommodationId);
            }

            var facility = await facilityDataSource.FindFacilityAsync(accommodation.FacilityId);

            var booking = new Contracts.Models.Booking
            {
                Id                = Guid.NewGuid(),
                User              = securityContext.GetCurrentUser(),
                AccommodationId   = accommodationId,
                Details           = details,
                AccommodationName = accommodation.Name,
                FacilityId        = facility != null ? facility.Id : 0,
                FacilityName      = facility?.Name,
                StreetAddress     = facility?.StreetAddress
            };

            await dataSource.CreateAsync(booking);

            return(booking);
        }
예제 #2
0
        public async Task <Booking> BookAsync(Guid accommodationId, BookingDetails details)
        {
            await accommodationService.CheckAccommodationAsync(accommodationId);

            var booking = new Booking
            {
                Id              = Guid.NewGuid(),
                User            = securityContext.GetCurrentUser(),
                AccommodationId = accommodationId,
                Details         = details
            };

            await dataSource.CreateAsync(booking);

            return(booking);
        }