private ErpService.ShippingInfo ErpProcessOrder(Order order) { ErpService.ShippingInfo info = ErpService.ProcessOrder(order); if (info.Status == ErpService.ShippingStatus.Success) { return(info); } throw new ErpService.ErpException("Info status = " + info.Status); }
private Result <bool> HandleUpdateOrder(Order order, ErpService.ShippingInfo shipping, List <OrderProcessingStatus> failedOrders) { return(UpdateShippedOrder(order, shipping) .OnFailure(error => { failedOrders.Add(new OrderProcessingStatus { OrderId = order.Id, ErrorMessage = error.ToString() }); // see note * return Result <bool> .Succeeded(); })); }
private Result <ErpService.ShippingInfo> ErpProcessOrder(Order order) { return(Result <ErpService.ShippingInfo> .ToResult(() => { ErpService.ShippingInfo info = ErpService.ProcessOrder(order); if (info.Status == ErpService.ShippingStatus.Success) { return info; } throw new ErpService.ErpException("Info status = " + info.Status); })); }
private void InformCustomer(ErpService.ShippingInfo info, Customer customer) { string mailTemplate = Repository.GetMailTemplate("ORDER"); string mailBody = String.Format(mailTemplate, customer.Name, info.EstimatedShippingDate); if (SmtpService.SendMail(customer.EmailAddress, "Order status", mailBody) == false) { throw new SmptException("Failed to send mail"); } }
private Result <bool> HandleInformCustomer(ErpService.ShippingInfo info, Customer customer) { var result = Result <bool> .FromBool(() => { string mailTemplate = Repository.GetMailTemplate("ORDER"); string mailBody = String.Format(mailTemplate, customer.Name, info.EstimatedShippingDate); return(SmtpService.SendMail(customer.EmailAddress, "Order status", mailBody)); }); return(result); }
private Result <bool> UpdateOrderAndInformCustomer( Order orderResult, Customer customerResult, ErpService.ShippingInfo shippingInfo, List <OrderProcessingStatus> failedOrders) { UpdateShippedOrder(orderResult, shippingInfo) .OnFailure(error => { failedOrders.Add(new OrderProcessingStatus { OrderId = orderResult.Id, ErrorMessage = error.ToString() }); // see note * }); InformCustomer(shippingInfo, customerResult); return(Result <bool> .Succeeded()); }
private Result <bool> UpdateShippedOrder(Order order, ErpService.ShippingInfo info) { order.Status = Order.OrderStatus.Shipped; order.TrackingId = info.TrackingCode; return(Result <bool> .FromBool(() => Repository.UpdateOrder(order))); }