public async Task <Unit> Handle(ChangeReservationSeat command, CancellationToken cancellationToken) { var reservation = await repository.FindById(command.ReservationId, cancellationToken) ?? throw NotFoundException.For <Reservation>(command.ReservationId); reservation.ChangeSeat(command.SeatId); await repository.Update(reservation, cancellationToken); await repository.SaveChanges(cancellationToken); return(Unit.Value); }
public void GivenNotFoundException_WhenMapped_ThenReturnsForbiddenHttpStatusWithProperMessage() { //Given var id = Guid.NewGuid(); var exception = NotFoundException.For <TestEntity>(id); //When var codeInfo = ExceptionToHttpStatusMapper.Map(exception); //Then codeInfo.Code.Should().Be(HttpStatusCode.NotFound); codeInfo.Message.Should().Be($"{typeof(TestEntity).Name} with id: {id} was not found."); }