public async Task <IActionResult> MakeReservation([FromBody] MakeReservationDto reservationDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = ReservationId.With(reservationDto.ReservationId); var reservationPlacedOrError = await _commandBus.PublishAsync(new MakeReservation( id, reservationDto.Name, reservationDto.Email, reservationDto.Arrival, reservationDto.Departure), CancellationToken.None); if (reservationPlacedOrError.IsSuccess) { return(NoContent()); } return(BadRequest(reservationPlacedOrError)); }
public async Task <IActionResult> UpdateContactInformation( [FromBody] ContactInformationDto newContactInformation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = ReservationId.With(newContactInformation.ReservationId); var contactInformationUpdatedOrError = await _commandBus.PublishAsync( new UpdateContactInformation( id, newContactInformation.Name, newContactInformation.Email), CancellationToken.None); if (contactInformationUpdatedOrError.IsSuccess) { return(NoContent()); } return(BadRequest(contactInformationUpdatedOrError)); }
public Task <ISagaId> LocateSagaAsync( IDomainEvent domainEvent, CancellationToken cancellationToken) { var identity = GetIdentityTypeForEvent(domainEvent); if (identity.GetType() == typeof(ReservationId)) // ED Consider using a MetaDataProvider; overkill now. { var reservationId = identity.Value; var orderSagaId = ReservationSagaId.With(ReservationId.With(reservationId).GetGuid()); return(Task.FromResult <ISagaId>(orderSagaId)); } return(Task.FromResult <ISagaId>(ReservationSagaId.New)); }
public async Task <IActionResult> FindOffer( [Required] Guid reservationId, [Required] DateTime arrival, [Required] DateTime departure) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = ReservationId.With(reservationId); var offersCreatedOrError = await _commandBus .PublishAsync(new CreateOffer(id, arrival, departure), CancellationToken.None); if (!offersCreatedOrError.IsSuccess) { return(BadRequest(offersCreatedOrError)); } var offer = _queryProcessor .Process(new GetOffers(id, arrival, departure), CancellationToken.None); return(Json(OfferDto.FromReservationOffer(offer))); }
public ReservationReadModel GetReservationById(Guid reservationId) { var id = ReservationId.With(reservationId); return(_queryProcessor.Process(new FindReservationById(id), CancellationToken.None)); }