public void Handle(CancelOrderBecauseOfError command) { var order = _repository.Find(command.OrderId); order.CancelBecauseOfError(command.ErrorCode, command.ErrorDescription); _repository.Save(order, command.Id.ToString()); }
public bool SendOrderCreationCommands(Guid orderId, int?ibsOrderId, bool isPrepaid, string clientLanguageCode, bool switchedCompany = false, string newCompanyKey = null, string newCompanyName = null, string market = null) { if (!ibsOrderId.HasValue || ibsOrderId <= 0) { var code = !ibsOrderId.HasValue || (ibsOrderId.Value >= -1) ? string.Empty : "_" + Math.Abs(ibsOrderId.Value); var errorCode = "CreateOrder_CannotCreateInIbs" + code; var errorCommand = new CancelOrderBecauseOfError { OrderId = orderId, ErrorCode = errorCode, ErrorDescription = _resources.Get(errorCode, clientLanguageCode) }; _commandBus.Send(errorCommand); return(false); } else if (switchedCompany) { var orderDetail = _orderDao.FindById(orderId); // Cancel order on current company IBS _ibsCreateOrderService.CancelIbsOrder(orderDetail.IBSOrderId, orderDetail.CompanyKey, orderDetail.Settings.Phone, orderDetail.AccountId); _commandBus.Send(new SwitchOrderToNextDispatchCompany { OrderId = orderId, IBSOrderId = ibsOrderId.Value, CompanyKey = newCompanyKey, CompanyName = newCompanyName, Market = market }); return(true); } else { _logger.LogMessage(string.Format("Adding IBSOrderId {0} to order {1}", ibsOrderId, orderId)); var ibsCommand = new AddIbsOrderInfoToOrder { OrderId = orderId, IBSOrderId = ibsOrderId.Value }; _commandBus.Send(ibsCommand); return(true); } }