public static void SendEmailNotification(SendEmailInfo emailInfo, string VariantId, string VarinatValue, string sku, string ProductUrl, AspxCommonInfo aspxCommonObj)
 {
     try
     {
         AspxOutStockNotifyProvider.SendEmailNotification(emailInfo, VariantId, VarinatValue, sku, ProductUrl, aspxCommonObj);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public static void ReturnSendEmail(AspxCommonInfo aspxCommonObj, SendEmailInfo sendEmailObj)
 {
     try
     {
         EmailTemplate.SendEmailForReturns(aspxCommonObj, sendEmailObj);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
       public static void SendEmailNotification(SendEmailInfo emailInfo, string VariantId, string VarinatValue, string sku, string ProductUrl, AspxCommonInfo aspxCommonObj)
       {
           try
           {
               AspxOutStockNotifyProvider.SendEmailNotification(emailInfo, VariantId, VarinatValue, sku, ProductUrl, aspxCommonObj);

           }
           catch (Exception e)
           {
               throw e;
           }
       }
 public static void SendEmailNotification(SendEmailInfo emailInfo, string VariantId, string VarinatValue, string sku, string ProductUrl, AspxCommonInfo aspxCommonObj)
 {
     try
     {
         EmailTemplate.SendOutOfNotification(aspxCommonObj, emailInfo, VariantId, VarinatValue, sku, ProductUrl);
         List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPU(aspxCommonObj);
         parameter.Add(new KeyValuePair <string, object>("itemSKU", sku));
         parameter.Add(new KeyValuePair <string, object>("VariantID", VariantId));
         OracleHandler sqlH = new OracleHandler();
         sqlH.ExecuteNonQuery("usp_Aspx_UpdateNotification", parameter);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
       public static void SendEmailNotification(SendEmailInfo emailInfo, string VariantId, string VarinatValue, string sku, string ProductUrl, AspxCommonInfo aspxCommonObj)
       {
           try
           {
               EmailTemplate.SendOutOfNotification(aspxCommonObj, emailInfo, VariantId, VarinatValue, sku, ProductUrl);
               List<KeyValuePair<string, object>> parameter = CommonParmBuilder.GetParamSPU(aspxCommonObj);
               parameter.Add(new KeyValuePair<string, object>("@itemSKU", sku));
               parameter.Add(new KeyValuePair<string, object>("@VariantID", VariantId));
               SQLHandler sqlH = new SQLHandler();
               sqlH.ExecuteNonQuery("usp_Aspx_UpdateNotification", parameter);

           }
           catch (Exception e)
           {
               throw e;
           }
       }
        public void SendEmailNotification(SendEmailInfo emailInfo, string VariantId, string VarinatValue, string sku, string ProductUrl, AspxCommonInfo aspxCommonObj) // not used In Item Detail Page
        {
            try
            {
                AspxOutStockNotifyController.SendEmailNotification(emailInfo, VariantId, VarinatValue, sku, ProductUrl, aspxCommonObj);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void ReturnSendEmail(AspxCommonInfo aspxCommonObj, SendEmailInfo sendEmailObj)
        {
            try
            {
                EmailTemplate.SendEmailForReturns(aspxCommonObj, sendEmailObj);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void SendEmailForReturns(AspxCommonInfo aspxCommonObj, SendEmailInfo sendEmailObj)
        {
            StoreSettingConfig ssc = new StoreSettingConfig();
            string logosrc = ssc.GetStoreSettingsByKey(StoreSetting.StoreLogoURL, aspxCommonObj.StoreID,
                                                       aspxCommonObj.PortalID, aspxCommonObj.CultureName);
            string src = HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + "/";
            string imgSrc = "http://" + src + logosrc;
            string serverPath = "http://" + src;

            char[] spliter = {','};
            string s = sendEmailObj.MessageBody;
            string[] values = s.Split('#');
            string msgTemplate = string.Empty;
            string returnID = string.Empty;
            string orderID = string.Empty;
            string item = string.Empty;
            string variant = string.Empty;
            string qty = string.Empty;
            string status = string.Empty;
            string action = string.Empty;

            returnID = values[1];
            orderID = values[0];
            item = values[2];
            variant = values[3];
            qty = values[4];
            status = values[5];
            action = values[6];

            AspxGetTemplates agt = new AspxGetTemplates();

            string messageTemplate = agt.ReturnNotificationEmailTemplate().ToString();
            if (messageTemplate != null)
            {
                string[] tokens = GetAllToken(messageTemplate);
                foreach (var token in tokens)
                {
                    switch (token)
                    {
                        case "%LogoSource%":
                            messageTemplate = messageTemplate.Replace(token, imgSrc);
                            break;
                        case "%DateTime%":
                            messageTemplate = messageTemplate.Replace(token, DateTime.Now.ToString("MM/dd/yyyy"));
                            break;
                        case "%ReturnID%":
                            messageTemplate = messageTemplate.Replace(token, returnID);
                            break;
                        case "%OrderID%":
                            messageTemplate = messageTemplate.Replace(token, orderID);
                            break;
                        case "%ItemName%":
                            messageTemplate = messageTemplate.Replace(token, item);
                            break;
                        case "%Variant%":
                            messageTemplate = messageTemplate.Replace(token, variant.Length > 0 ? variant : "N/A");
                            break;
                        case "%Quantity%":
                            messageTemplate = messageTemplate.Replace(token, qty);
                            break;
                        case "%ReturnStatus%":
                            messageTemplate = messageTemplate.Replace(token, status.Length > 0 ? status : "N/A");
                            break;
                        case "%ReturnAction%":
                            messageTemplate = messageTemplate.Replace(token, action.Length > 0 ? action : "N/A");
                            break;
                        case "%ServerPath%":
                            messageTemplate = messageTemplate.Replace(token, src);
                            break;
                        case "%DateYear%":
                            messageTemplate = messageTemplate.Replace(token, System.DateTime.Now.Year.ToString());
                            break;
                    }
                }
            }
            msgTemplate = sendEmailObj.Message;
            string emailSuperAdmin;
            string emailSiteAdmin;

            SageFrameConfig pagebase = new SageFrameConfig();
            emailSuperAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SuperUserEmail);
            emailSiteAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SiteAdminEmailAddress);
            MailHelper.SendMailNoAttachment(sendEmailObj.SenderEmail, sendEmailObj.ReceiverEmail, sendEmailObj.Subject,
                                            messageTemplate, emailSiteAdmin, emailSuperAdmin);
        }
        public static void SendOutOfNotification(AspxCommonInfo aspxCommonObj, SendEmailInfo emailInfo, string variantId,
                                                 string variantValue, string Sku, string ProductUrl)
        {
            StoreSettingConfig ssc = new StoreSettingConfig();
            string logosrc = ssc.GetStoreSettingsByKey(StoreSetting.StoreLogoURL, aspxCommonObj.StoreID,
                                                       aspxCommonObj.PortalID, aspxCommonObj.CultureName);
            List<MessageManagementInfo> template =
                MessageManagementController.GetMessageTemplateByMessageTemplateTypeID(
                    SystemSetting.OUT_OF_STOCK_NOTIFICATION, aspxCommonObj.PortalID);
            foreach (MessageManagementInfo messageToken in template)
            {
                string messageTemplate = messageToken.Body.ToString();
                string src = HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + "/";
                if (template != null)
                {
                    string[] tokens = GetAllToken(messageTemplate);
                    foreach (string token in tokens)
                    {
                        switch (token)
                        {
                            case "%DateTime%":
                                messageTemplate = messageTemplate.Replace(token,
                                                                          System.DateTime.Now.ToString("MM/dd/yyyy"));
                                break;
                            case "%Username%":
                                messageTemplate = messageTemplate.Replace(token, emailInfo.SenderName);
                                break;
                            case "%MessageDetails%":
                                messageTemplate = messageTemplate.Replace(token, emailInfo.Subject);
                                break;
                            case "%ItemDetailsTable%":
                                messageTemplate = messageTemplate.Replace(token, emailInfo.MessageBody);
                                break;
                            case "%LogoSource%":
                                string imgSrc = "http://" + src + logosrc;
                                messageTemplate = messageTemplate.Replace(token, imgSrc);
                                break;
                            case "%ServerPath%":
                                messageTemplate = messageTemplate.Replace(token, "http://" + src);
                                break;
                            case "%DateYear%":
                                messageTemplate = messageTemplate.Replace(token, System.DateTime.Now.Year.ToString());
                                break;
                        }
                    }
                }

                char[] spliter = {','};
                emailInfo.ReceiverEmail = emailInfo.ReceiverEmail.Substring(0, emailInfo.ReceiverEmail.LastIndexOf(','));
                variantId = variantId.Substring(0, variantId.LastIndexOf(','));
                variantValue = variantValue.Substring(0, variantValue.LastIndexOf('@'));

                string[] receiverIDs = emailInfo.ReceiverEmail.Split(spliter);
                string[] variantIds = variantId.Split(spliter);
                string[] variantValues = variantValue.Split('@');
                for (int i = 0; i < receiverIDs.Length; i++)
                {
                    string msgTemplate = string.Empty;
                    string receiverEmailId = receiverIDs[i];
                    string varId = variantIds[i];
                    string varValue = variantValues[i];
                    msgTemplate = messageTemplate;
                    msgTemplate = msgTemplate.Replace("%UserEmail%", receiverEmailId);
                    if (varValue != "")
                    {
                        var sku = Sku + '(' + varValue + ')';
                        msgTemplate = msgTemplate.Replace("#sku#", sku);
                    }
                    else
                    {
                        msgTemplate = msgTemplate.Replace("#sku#", Sku);
                    }
                    if (varId != "")
                    {
                        msgTemplate = msgTemplate.Replace("#server#",
                                                          ProductUrl + "item/" + Sku + ".aspx?varId=" + varId);
                    }
                    else
                    {
                        msgTemplate = msgTemplate.Replace("#server#", ProductUrl + "item/" + Sku + ".aspx");
                    }
                    emailInfo.Subject = messageToken.Subject;
                    string emailSuperAdmin;
                    string emailSiteAdmin;
                    SageFrameConfig pagebase = new SageFrameConfig();
                    emailSuperAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SuperUserEmail);
                    emailSiteAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SiteAdminEmailAddress);
                    MailHelper.SendMailNoAttachment(emailInfo.SenderEmail, receiverEmailId, emailInfo.Subject,
                                                    msgTemplate, emailSiteAdmin, emailSuperAdmin);

                }
            }
        }