public async Task ValidateAsync(IReservationContainer reservationContainer) { if (reservationContainer == null) { throw new ArgumentNullException(nameof(reservationContainer)); } var reservation = await this.GetBy(reservationContainer); if (reservationContainer.ReservationId.HasValue && reservation == null) { throw new InvalidOperationException($"Reservation not found by id {reservationContainer.ReservationId}"); } }
public async Task <Reservation> GetByAsync(IReservationContainer reservation) { return(reservation.ReservationId.HasValue ? this.Mapper.Map <Reservation>(await this.Context.Reservation.FirstOrDefaultAsync(x => x.Id == reservation.ReservationId)) : null); }
private Task <Reservation> GetBy(IReservationContainer departmentContainer) { return(this.ReservationDataAccess.GetByAsync(departmentContainer)); }