public override AddOrderCommand Handle(AddOrderCommand addOrderCommand) { using (var scope = _ordersDao.BeginTransaction()) { base.logger.DebugFormat(string.Format("Writing new order for customer: {0}", addOrderCommand.CustomerName)); var inserted = _ordersDao.Add( new Order( customerName: addOrderCommand.CustomerName, orderDescription: addOrderCommand.OrderDescription, dueDate: addOrderCommand.OrderDueDate ) ); scope.Commit(); addOrderCommand.OrderId = inserted.Id; } _commandProcessor.Publish( new OrderAddedEvent( addOrderCommand.CustomerName, addOrderCommand.OrderDescription, addOrderCommand.OrderDueDate)); return(base.Handle(addOrderCommand)); }
public override EditOrderCommand Handle(EditOrderCommand editOrderCommand) { using (var scope = _ordersDao.BeginTransaction()) { Order order = _ordersDao.FindById(editOrderCommand.OrderId); order.CustomerName = editOrderCommand.OrderName; order.OrderDescription = editOrderCommand.OrderDescription; order.DueDate = editOrderCommand.OrderDueDate; _ordersDao.Update(order); scope.Commit(); } return(base.Handle(editOrderCommand)); }
public override CompleteOrderCommand Handle(CompleteOrderCommand completeOrderCommand) { using (var scope = _ordersDao.BeginTransaction()) { Order order = _ordersDao.FindById(completeOrderCommand.OrderId); if (order != null) { order.CompletionDate = completeOrderCommand.CompletionDate; _ordersDao.Update(order); scope.Commit(); } else { throw new ArgumentOutOfRangeException("completeOrderCommand", completeOrderCommand, "Could not find the task to complete"); } } return(base.Handle(completeOrderCommand)); }
public override AddOrderCommand Handle(AddOrderCommand addOrderCommand) { using (var scope = _ordersDao.BeginTransaction()) { var inserted = _ordersDao.Add( new Order( customerName: addOrderCommand.OrderName, orderDescription: addOrderCommand.OrderDescription, dueDate: addOrderCommand.OrderDueDate ) ); scope.Commit(); addOrderCommand.OrderId = inserted.Id; } return(base.Handle(addOrderCommand)); }