public IHttpActionResult Post(Guid id, CompletePreparationCommand cmd) { try { var command = new CompleteOrder(id, cmd.Version); handler.Handle(command); return(Ok()); } catch (AggregateNotFoundException) { return(NotFound()); } catch (AggregateDeletedException) { return(Conflict()); } }
public void Should_raise_prepared_event_when_barista_completes_preparation() { var id = Guid.NewGuid(); var handler = new BaristaOrderCommandHandlers(repository); var e = new OrderPlaced(id, Guid.NewGuid(), 1); var eventHandler = new CashierOrderEventHandler(repository); eventHandler.Apply(e); var order = repository.GetById <BaristaOrder>(id); Assert.False(order.IsCompleted); var command = new CompleteOrder(id, order.Version); handler.Handle(command); order = repository.GetById <BaristaOrder>(id); Assert.True(order.IsCompleted); }