Пример #1
0
        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);
        }
Пример #2
0
 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();
     }));
 }
Пример #3
0
        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);
            }));
        }
Пример #4
0
        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");
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
        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());
        }
Пример #7
0
 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)));
 }