public bool ProcessOrder(Order order)
 {
     try
     {
         Log.WriteInfoLog("Attempting to process Kurt Adler items (ref: #" + order.id + ")");
         var orderData = new List<EmailOrderData>();
         foreach (var item in order.line_items)
         {
             if (item.sku.Substring(0, 2) == Supplier.KurtAdlerPrefix)
             {
                 orderData.Add(new EmailOrderData()
                 {
                     //Required Kurt Adler data
                     ShipToName = order.shipping_address.first_name + " " + order.shipping_address.last_name,
                     ShipToAddressLine1 = order.shipping_address.address1,
                     ShipToAddressLine2 = order.shipping_address.address2,
                     ShipToCity = order.shipping_address.city,
                     ShipToState = order.shipping_address.province,
                     ShipToZip = order.shipping_address.zip,
                     CountryCode = order.shipping_address.country_code,
                     ItemNumber = item.sku.Substring(2),
                     ItemTitle = item.name,
                     OrderQuantity = item.quantity,
                     PoNumber = order.order_number
                 });
             }
         }
         if (orderData != null && orderData.Count() > 0)
         {
             if (SendEmailToKurtAdler(orderData))
             {
                 //Email sent successfully
                 return true;
             }
             else
             {
                 //Unable to send email to Kurt Adler
                 Log.WriteInfoLog("Unable to send email to Kurt Adler");
                 return false;
             }
         }
         else
         {
             //No items in list
             Log.WriteInfoLog("Error adding items to Kurt Adler order list");
             return false;
         }
     }
     catch (Exception ex)
     {
         Log.WriteErrorLog(ex);
         return false;
     }
 }
        public bool ProcessEvergreenOrder(Order order)
        {
            try
            {
                Log.WriteInfoLog("Attempting to process Evergreen items (ref: #" + order.id + ")");
                var orderData = new List<EvergreenOrderData>();
                foreach (var item in order.line_items)
                {
                    if (item.sku.Substring(0, 2) == Supplier.EvergreenPrefix)
                    {
                        if (order.shipping_address.country_code == "US")
                        {
                            //Set country code according to Evergreen spec
                            order.shipping_address.country_code = "USA";
                        }
                        orderData.Add(new EvergreenOrderData()
                            {
                                //Required Evergreen data
                                ClientId = Supplier.EvergreenClientId,
                                PoNumber = order.order_number,
                                PoDate = FormatPoDate(order.created_at),
                                ShipMethod = Supplier.PreferredShipper,
                                ShipToName = order.shipping_address.first_name + " " + order.shipping_address.last_name,
                                ShipToAddressLine1 = order.shipping_address.address1,
                                ShipToAddressLine2 = order.shipping_address.address2,
                                ShipToCity = order.shipping_address.city,
                                ShipToState = order.shipping_address.province,
                                ShipToZip = order.shipping_address.zip,
                                CountryCode = order.shipping_address.country_code,
                                ClientItemId = item.sku,
                                ClientItemName = item.name,
                                Upc = item.sku.Remove(0, 2),
                                OrderQuantity = item.quantity
                            });
                    }
                }
                if (orderData != null && orderData.Count() > 0)
                {
                    var excelFileName = CreateRequiredXlsDoc(orderData);

                    if (excelFileName != string.Empty)
                    {
                        if (SendExcelToEvergreen(excelFileName))
                        {
                            //Excel sent to Evergreen successfully
                            return true;
                        }
                        else
                        {
                            //Unable to send excel file to Evergreen via FTP
                            Log.WriteInfoLog("Unable to send Excel file to Evergreen via FTP");
                            return false;
                        }
                    }
                    else
                    {
                        //Unable to create excel file
                        Log.WriteInfoLog("Unable to create Excel file");
                        return false;
                    }
                }
                else
                {
                    //No items in list
                    Log.WriteInfoLog("Error adding items to Evergreen order list");
                    return false;
                }
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog(ex);
                return false;
            }
        }
Example #3
0
 public bool ProcessOrder(Order order)
 {
     try
     {
         Log.WriteInfoLog("Attempting to process LipLidz items (ref: #" + order.id + ")");
         var orderData = new List<EmailOrderData>();
         foreach (var item in order.line_items)
         {
             if (item.sku.Substring(0, 2) == Supplier.LipLidzPrefix)
             {
                 var color = string.Empty;
                 if (item.sku.Contains("WHITE"))
                 {
                     item.sku = item.sku.Replace("WHITE", "");
                     color = "WHITE";
                 }
                 if (item.sku.Contains("LIME"))
                 {
                     item.sku = item.sku.Replace("LIME", "");
                     color = "LIME";
                 }
                 if (item.sku.Contains("MANGO"))
                 {
                     item.sku = item.sku.Replace("MANGO", "");
                     color = "MANGO";
                 }
                 if (item.sku.Contains("TEAL"))
                 {
                     item.sku = item.sku.Replace("TEAL", "");
                     color = "TEAL";
                 }
                 if (item.sku.Contains("WATERMELON"))
                 {
                     item.sku = item.sku.Replace("WATERMELON", "");
                     color = "WATERMELON";
                 }
                 if (item.sku.Contains("ASSORTED"))
                 {
                     item.sku = item.sku.Replace("ASSORTED", "");
                     color = "ASSORTED";
                 }
                 orderData.Add(new EmailOrderData()
                 {
                     //Required LipLidz data
                     ShipToName = order.shipping_address.first_name + " " + order.shipping_address.last_name,
                     ShipToAddressLine1 = order.shipping_address.address1,
                     ShipToAddressLine2 = order.shipping_address.address2,
                     ShipToCity = order.shipping_address.city,
                     ShipToState = order.shipping_address.province,
                     ShipToZip = order.shipping_address.zip,
                     CountryCode = order.shipping_address.country_code,
                     ItemNumber = item.sku.Substring(2),
                     ItemTitle = item.name,
                     OrderQuantity = item.quantity,
                     PoNumber = order.order_number,
                     Color = color
                 });
             }
         }
         if (orderData != null && orderData.Count() > 0)
         {
             if (SendEmailToLipLidz(orderData))
             {
                 //Email sent successfully
                 return true;
             }
             else
             {
                 //Unable to send email to LipLidz
                 Log.WriteInfoLog("Unable to send email to LipLidz");
                 return false;
             }
         }
         else
         {
             //No items in list
             Log.WriteInfoLog("Error adding items to LipLidz order list");
             return false;
         }
     }
     catch (Exception ex)
     {
         Log.WriteErrorLog(ex);
         return false;
     }
 }
Example #4
0
 public bool ProcessOrder(Order order)
 {
     try
     {
         Log.WriteInfoLog("Attempting to process Midwest items (ref: #" + order.id + ")");
         var orderData = new List<EmailOrderData>();
         foreach (var item in order.line_items)
         {
             if (item.sku.Substring(0, 2) == Supplier.MidwestPrefix)
             {
                 if (item.name.Contains("Set of "))
                 {
                     try
                     {
                         int minQty;
                         var unitQty = Convert.ToInt32(item.quantity);
                         var minQtyStr = item.name.Substring(item.name.LastIndexOf("Set of ") + 7);
                         if (Int32.TryParse(minQtyStr, out minQty))
                         {
                             item.quantity = Convert.ToString(unitQty * minQty);
                             int index = item.name.IndexOf("Set of ");
                             if (index > 0)
                             {
                                 item.name = item.name.Substring(0, index);
                             }
                         }
                     }
                     catch (Exception ex)
                     {
                         Log.WriteErrorLog(ex);
                     }
                 }
                 orderData.Add(new EmailOrderData()
                 {
                     //Required Midwest data
                     ShipToName = order.shipping_address.first_name + " " + order.shipping_address.last_name,
                     ShipToAddressLine1 = order.shipping_address.address1,
                     ShipToAddressLine2 = order.shipping_address.address2,
                     ShipToCity = order.shipping_address.city,
                     ShipToState = order.shipping_address.province,
                     ShipToZip = order.shipping_address.zip,
                     CountryCode = order.shipping_address.country_code,
                     ItemNumber = item.sku.Substring(2),
                     ItemTitle = item.name,
                     OrderQuantity = item.quantity,
                     PoNumber = order.order_number
                 });
             }
         }
         if (orderData != null && orderData.Count() > 0)
         {
             if (SendEmailToMidwest(orderData))
             {
                 //Email sent successfully
                 return true;
             }
             else
             {
                 //Unable to send email to Midwest
                 Log.WriteInfoLog("Unable to send email to Midwest");
                 return false;
             }
         }
         else
         {
             //No items in list
             Log.WriteInfoLog("Error adding items to Midwest order list");
             return false;
         }
     }
     catch (Exception ex)
     {
         Log.WriteErrorLog(ex);
         return false;
     }
 }