public async Task <IActionResult> UpdateForRentalDates(long id, [FromBody] UpdateForRentalDatesCommand command) { if (await authService.CheckIfBanned(this.User).ConfigureAwait(false)) { return(this.Forbid()); } command.ApartmentId = id; await this.mediator.Send(command).ConfigureAwait(false); return(this.Ok()); }
public async Task UpdatesForRentalDates() { var requestedDate = new DateTime(year: 2019, month: 5, day: 17); var request = new UpdateForRentalDatesCommand() { ApartmentId = this.dbApartment.Id, ForRentalDates = new[] { requestedDate } }; await this.sut.Handle(request, CancellationToken.None).ConfigureAwait(false); var dbRentalDates = await this.Context.ForRentalDates .Where(frd => frd.ApartmentId == request.ApartmentId && !frd.IsDeleted) .ToListAsync() .ConfigureAwait(false); var rentalDate = Assert.Single(dbRentalDates); Assert.Equal(requestedDate, rentalDate.Date); }