public async Task AddAsync(RoomBookingByGuest entity) { Batch batch = RepositoryContext.CreateBatch(); AddInBatch(entity, batch); AddInBatch((RoomBookingByHotel)entity, batch); await batch.CommitAsync(); }
public async Task AddBookingAsync(Guid?guestId, Guid?hotelId, DateTime startReserveTime, DateTime endReserveTime, string type) { var result = await GetGuestByIdAsync(guestId); if (result.Count() < 1) { throw new Exception("Guest does not exist"); } IEnumerable <Room> freeRooms = await GetFreeRoomByHotelIdByBookingPeriodAsync(hotelId, startReserveTime, endReserveTime, type); RoomBookingByGuest roomToBook = new RoomBookingByGuest(guestId, freeRooms.First(), startReserveTime, endReserveTime); Task.WaitAll(mapper.InsertAsync((RoomBookingByHotel)roomToBook), mapper.InsertAsync(roomToBook)); }