public void LoadSetting()
    {
        var pw = new PayPalWCFService();
        var orderdata2 =  (OrderDetailsCollection)HttpContext.Current.Session["OrderCollection"];

        try
        {
            List<PayPalSettingInfo> sf = pw.GetAllPayPalSetting(int.Parse(Session["GateWay"].ToString()), storeID,
                                                                portalID);

            string postUrl;
            if (bool.Parse(sf[0].IsTestPaypal))
            {
                postUrl = "https://www.sandbox.paypal.com/us/cgi-bin/webscr";
                HttpContext.Current.Session["IsTestPayPal"] = true;

            }
            else
            {
                postUrl = "https://www.paypal.com/us/cgi-bin/webscr";
                HttpContext.Current.Session["IsTestPayPal"] = false;

            }
            string ids = Session["OrderID"].ToString() + "#" + storeID + "#" + portalID + "#" + UserName + "#" +
                         customerID + "#" + SessionCode + "#" + Session["IsTestPayPal"].ToString() + "#" +
                         Session["GateWay"].ToString();


            var url = new StringBuilder();

            url.Append(postUrl + "?cmd=_cart&business=" +
                       HttpUtility.UrlEncode(sf[0].BusinessAccount.Trim()));
            string serviceType = string.Empty;
            if (Session["ServiceType"] != null)
            {
                serviceType = Session["ServiceType"].ToString();
            }
            if (serviceType.ToLower() == "true")
            {
                var appointmentInfo = new BookAppointmentInfo();
                if (HttpContext.Current.Session["AppointmentCollection"] != null)
                {
                    appointmentInfo = (BookAppointmentInfo) HttpContext.Current.Session["AppointmentCollection"];
                }
                int nCount = 1;
                double itemPrice = Convert.ToDouble(appointmentInfo.ServiceProductPrice)*Rate;
                url.AppendFormat("&item_name_" + nCount + "={0}",
                                 HttpUtility.UrlEncode(appointmentInfo.ServiceProductName));
                url.AppendFormat("&amount_" + nCount + "={0}",
                                 HttpUtility.UrlEncode(Math.Round(itemPrice, 2).ToString()));
               
                double discountAll = 0.00;
                double couponDiscount = 0.00;
                double taxAll = 0.00;
                double shippingCostAll = 0.00;

                url.AppendFormat("&num_cart_items={0}", HttpUtility.UrlEncode(nCount.ToString()));
                url.AppendFormat("&discount_amount_cart={0}",
                                 HttpUtility.UrlEncode(Math.Round((discountAll + couponDiscount), 2).ToString()));
                url.AppendFormat("&tax_cart={0}", HttpUtility.UrlEncode(Math.Round(taxAll, 2).ToString()));
                url.AppendFormat("&no_shipping={0}", HttpUtility.UrlEncode("1"));
                url.AppendFormat("&shipping_1={0}", HttpUtility.UrlEncode(Math.Round(shippingCostAll, 2).ToString()));
                url.AppendFormat("&currency_code={0}", HttpUtility.UrlEncode(MainCurrency));

                if (sf[0].ReturnUrl != null && sf[0].ReturnUrl.Trim() != "")
                {

                 
                                                          var serviceSuccessPage = "Appointment-Success.aspx";
                    var successPageURL = sf[0].ReturnUrl.Substring(0, sf[0].ReturnUrl.LastIndexOf("/")) + "/" +serviceSuccessPage;
                    url.AppendFormat("&return={0}", HttpUtility.UrlEncode(successPageURL.ToString()));
                }
                if (!string.IsNullOrEmpty(sf[0].VerificationUrl))
                    url.AppendFormat("&notify_url={0}", HttpUtility.UrlEncode(sf[0].VerificationUrl));
                if (!string.IsNullOrEmpty(sf[0].CancelUrl))
                    url.AppendFormat("&cancel_return={0}", HttpUtility.UrlEncode(sf[0].CancelUrl));

                url.AppendFormat("&upload={0}", HttpUtility.UrlEncode("1"));
                url.AppendFormat("&rm={0}", HttpUtility.UrlEncode("1"));

                url.AppendFormat("&custom={0}", HttpUtility.UrlEncode(ids));
                Response.Redirect(url.ToString(), false);
            }            
        }
        catch (Exception ex)
        {
            lblnotity.Text = "Something goes wrong, hit refresh or go back to checkout";
            clickhere.Visible = false;
            ProcessException(ex);
        }

    }
        public static bool SaveBookAppointment(int appointmentId, AspxCommonInfo aspxCommonObj, BookAppointmentInfo obj)
        {
            var isSuccess = false;

            try
            {
                AspxServiceProvider.SaveBookAppointment(appointmentId, aspxCommonObj, obj);
                isSuccess = true;
            }
            catch (Exception)
            {
                isSuccess = false;
            }
            return(isSuccess);
        }
    public void LoadSetting()
    {
        var pw = new PayPalWCFService();
        var orderdata2 = (OrderDetailsCollection)HttpContext.Current.Session["OrderCollection"];

        try
        {
            List<PayPalSettingInfo> sf = pw.GetAllPayPalSetting(CheckOutSessions.Get<int>("GateWay", 0), storeID,
                                                                portalID);

            string postUrl;
            if (bool.Parse(sf[0].IsTestPaypal))
            {
                postUrl = "https://www.sandbox.paypal.com/us/cgi-bin/webscr";
                HttpContext.Current.Session["IsTestPayPal"] = true;

            }
            else
            {
                postUrl = "https://www.paypal.com/us/cgi-bin/webscr";
                HttpContext.Current.Session["IsTestPayPal"] = false;

            }
            string ids = HttpContext.Current.Session["OrderID"].ToString() + "#" + storeID + "#" + portalID + "#" + UserName + "#" +
                         customerID + "#" + SessionCode + "#" + HttpContext.Current.Session["IsTestPayPal"].ToString() + "#" +
                       CheckOutSessions.Get<int>("GateWay", 0);


            var url = new StringBuilder();

            url.Append(postUrl + "?cmd=_cart&business=" +
                       HttpUtility.UrlEncode(sf[0].BusinessAccount.Trim()));
            string serviceType = string.Empty;
            if (HttpContext.Current.Session["ServiceType"] != null)
            {
                serviceType = HttpContext.Current.Session["ServiceType"].ToString();
            }
            if (serviceType.ToLower() == "true")
            {
                var appointmentInfo = new BookAppointmentInfo();
                if (HttpContext.Current.Session["AppointmentCollection"] != null)
                {
                    appointmentInfo = (BookAppointmentInfo)HttpContext.Current.Session["AppointmentCollection"];
                }
                int nCount = 1;
                double itemPrice = Convert.ToDouble(appointmentInfo.ServiceProductPrice) * Rate;
                url.AppendFormat("&item_name_" + nCount + "={0}",
                                 HttpUtility.UrlEncode(appointmentInfo.ServiceProductName));
                url.AppendFormat("&amount_" + nCount + "={0}",
                                 HttpUtility.UrlEncode(Math.Round(itemPrice, 2).ToString()));
               
                double discountAll = 0.00;
                double couponDiscount = 0.00;
                double taxAll = 0.00;
                double shippingCostAll = 0.00;

                url.AppendFormat("&num_cart_items={0}", HttpUtility.UrlEncode(nCount.ToString()));
                url.AppendFormat("&discount_amount_cart={0}",
                                 HttpUtility.UrlEncode(Math.Round((discountAll + couponDiscount), 2).ToString()));
                url.AppendFormat("&tax_cart={0}", HttpUtility.UrlEncode(Math.Round(taxAll, 2).ToString()));
                url.AppendFormat("&no_shipping={0}", HttpUtility.UrlEncode("1"));
                url.AppendFormat("&shipping_1={0}", HttpUtility.UrlEncode(Math.Round(shippingCostAll, 2).ToString()));
                url.AppendFormat("&currency_code={0}", HttpUtility.UrlEncode(MainCurrency));

                if (sf[0].ReturnUrl != null && sf[0].ReturnUrl.Trim() != "")
                {


                                                          var serviceSuccessPage = "Appointment-Success.aspx";
                    var successPageURL = sf[0].ReturnUrl.Substring(0, sf[0].ReturnUrl.LastIndexOf("/")) + "/" + serviceSuccessPage;
                    url.AppendFormat("&return={0}", HttpUtility.UrlEncode(successPageURL.ToString()));
                }
                if (!string.IsNullOrEmpty(sf[0].VerificationUrl))
                    url.AppendFormat("&notify_url={0}", HttpUtility.UrlEncode(sf[0].VerificationUrl));
                if (!string.IsNullOrEmpty(sf[0].CancelUrl))
                    url.AppendFormat("&cancel_return={0}", HttpUtility.UrlEncode(sf[0].CancelUrl));

                url.AppendFormat("&upload={0}", HttpUtility.UrlEncode("1"));
                url.AppendFormat("&rm={0}", HttpUtility.UrlEncode("1"));

                url.AppendFormat("&custom={0}", HttpUtility.UrlEncode(ids));
                HttpContext.Current.Response.Redirect(url.ToString(), false);
            }
            else
            {
                List<CartInfoforPaypal> cd = pw.GetCartDetails(storeID, portalID, customerID, UserName,
                                                               CultureName, SessionCode);
                int nCount = 1;


                foreach (CartInfoforPaypal oItem in cd)
                {
                    double itemPrice = Convert.ToDouble(oItem.Price) * Rate;
                    url.AppendFormat("&item_name_" + nCount + "={0}", HttpUtility.UrlEncode(oItem.ItemName));
                    url.AppendFormat("&amount_" + nCount + "={0}",
                                     HttpUtility.UrlEncode(Math.Round(itemPrice, 2).ToString()));
                    url.AppendFormat("&quantity_" + nCount + "={0}", HttpUtility.UrlEncode(oItem.Quantity.ToString()));
                    nCount++;
                }
                nCount--;
                decimal gcamount = 0;

                List<GiftCardUsage> list = CheckOutSessions.Get<List<GiftCardUsage>>("UsedGiftCard");// (List<GiftCardUsage>)Session["UsedGiftCard"];

                if (list.Count > 0)
                    gcamount = list.Sum(e => e.ReducedAmount);


                double discountAll = CheckOutSessions.Get<double>("DiscountAmount", 0)+ Convert.ToDouble(gcamount.ToString()) * Rate;
                double couponDiscount = (double)orderdata2.ObjOrderDetails.CouponDiscountAmount * Rate;
                double taxAll =CheckOutSessions.Get<double>("TaxAll", 0) * Rate;
                double shippingCostAll = CheckOutSessions.Get<double>("ShippingCostAll", 0)  * Rate;
                url.AppendFormat("&num_cart_items={0}", HttpUtility.UrlEncode(nCount.ToString()));
                url.AppendFormat("&discount_amount_cart={0}",
                                 HttpUtility.UrlEncode(Math.Round((discountAll + couponDiscount), 2).ToString()));
                url.AppendFormat("&tax_cart={0}", HttpUtility.UrlEncode(Math.Round(taxAll, 2).ToString()));
                url.AppendFormat("&no_shipping={0}", HttpUtility.UrlEncode("1"));
                url.AppendFormat("&shipping_1={0}", HttpUtility.UrlEncode(Math.Round(shippingCostAll, 2).ToString()));
                url.AppendFormat("&currency_code={0}", HttpUtility.UrlEncode(MainCurrency));

                if (sf[0].ReturnUrl != null && sf[0].ReturnUrl.Trim() != "")
                    url.AppendFormat("&return={0}", HttpUtility.UrlEncode(sf[0].ReturnUrl.ToString()));
                if (!string.IsNullOrEmpty(sf[0].VerificationUrl))
                    url.AppendFormat("&notify_url={0}", HttpUtility.UrlEncode(sf[0].VerificationUrl));
                if (!string.IsNullOrEmpty(sf[0].CancelUrl))
                    url.AppendFormat("&cancel_return={0}", HttpUtility.UrlEncode(sf[0].CancelUrl));

                url.AppendFormat("&upload={0}", HttpUtility.UrlEncode("1"));
                url.AppendFormat("&rm={0}", HttpUtility.UrlEncode("1"));

                url.AppendFormat("&custom={0}", HttpUtility.UrlEncode(ids));

                HttpContext.Current.Response.Redirect(url.ToString(), false);
            }
        }
        catch
        {
            lblnotity.Text = "Something goes wrong, hit refresh or go back to checkout";
            clickhere.Visible = false;
            //ProcessException(ex);
        }

    }
        public void SendMailNotificatiion(int storeId, int portalId, string cultureName, BookAppointmentInfo objInfo)
        {
            StoreSettingConfig ssc     = new StoreSettingConfig();
            string             logosrc = ssc.GetStoreSettingsByKey(StoreSetting.StoreLogoURL, storeId, portalId, cultureName);
            string             name    = "Appointment Approval - Email";
            List <KeyValuePair <string, object> > parameter = new List <KeyValuePair <string, object> >();

            parameter.Add(new KeyValuePair <string, object>("@PortalID", portalId));
            parameter.Add(new KeyValuePair <string, object>("@CultureName", cultureName));
            parameter.Add(new KeyValuePair <string, object>("@MessageTemplateTypeName", name));
            SQLHandler sql = new SQLHandler();

            int messageTemplateTypeId = sql.ExecuteNonQuery("[dbo].[usp_Aspx_GetMessageTemplateTypeID]", parameter, "@MessageTemplateID");
            MessageManagementController msgController = new MessageManagementController();
            var template = msgController.GetMessageTemplate(messageTemplateTypeId, portalId);

            string messageTemplate = template.Body;
            string src             = HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + "/";

            string receiverEmailID = objInfo.Email;
            string subject         = template.Subject;
            string senderEmail     = template.MailFrom;
            var    headerMsg       = string.Empty;
            var    customMessage   = "";

            if (objInfo.AppointmentID > 0)
            {
                headerMsg = "status has been modified as follow.";
            }
            else if (objInfo.AppointmentID == 0)
            {
                headerMsg = "has been scheduled as following date and time.";
            }
            if (template != null)
            {
                string[] tokens = GetAllToken(messageTemplate);
                foreach (var token in tokens)
                {
                    switch (token)
                    {
                    case "%LogoSource%":
                        string imgSrc = src + logosrc;
                        messageTemplate = messageTemplate.Replace(token, imgSrc);
                        break;

                    case "%DateTime%":
                        messageTemplate = messageTemplate.Replace(token, DateTime.Now.ToString("MM/dd/yyyy"));
                        break;

                    case "%PreferredDate%":
                        messageTemplate = messageTemplate.Replace(token, objInfo.PreferredDate.ToString("MM/dd/yyyy"));
                        break;

                    case "%PreferredTime%":
                        messageTemplate = messageTemplate.Replace(token, objInfo.PreferredTime);
                        break;

                    case "%PreferredTimeInterval%":
                        messageTemplate = messageTemplate.Replace(token, objInfo.PreferredTimeInterval);
                        break;

                    case "%AppointmentStatus%":
                        messageTemplate = messageTemplate.Replace(token, objInfo.AppointmentStatusName);
                        break;

                    case "%ServerPath%":
                        messageTemplate = messageTemplate.Replace(token, src);
                        break;

                    case "%DateYear%":
                        messageTemplate = messageTemplate.Replace(token, System.DateTime.Now.Year.ToString());
                        break;

                    case "%AppointmentHeadingMessage%":
                        messageTemplate = messageTemplate.Replace(token, headerMsg);
                        break;

                    case "%AppointmentCustomMessage%":
                        messageTemplate = messageTemplate.Replace(token, customMessage);
                        break;

                    case "%ServiceProductName%":
                        messageTemplate = messageTemplate.Replace(token, objInfo.ServiceProductName);
                        break;
                    }
                }
            }

            SageFrameConfig pagebase        = new SageFrameConfig();
            string          emailSuperAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SuperUserEmail);
            string          emailSiteAdmin  = pagebase.GetSettingsByKey(SageFrameSettingKeys.SiteAdminEmailAddress);

            MailHelper.SendMailNoAttachment(senderEmail, receiverEmailID, subject, messageTemplate, emailSiteAdmin, emailSuperAdmin);
        }
        public bool SaveBookAppointment(int appointmentId, AspxCommonInfo aspxCommonObj, BookAppointmentInfo obj)
        {
            var isSuccess = false;

            try
            {
                List <KeyValuePair <string, object> > parameter = new List <KeyValuePair <string, object> >();
                parameter.Add(new KeyValuePair <string, object>("@AppointmentID", appointmentId));
                parameter.Add(new KeyValuePair <string, object>("@OrderID", obj.OrderID));
                parameter.Add(new KeyValuePair <string, object>("@ServiceCategoryID", obj.ServiceCategoryID));
                parameter.Add(new KeyValuePair <string, object>("@ServiceProductID", obj.ServiceProductID));
                parameter.Add(new KeyValuePair <string, object>("@ServiceProductPrice", obj.ServiceProductPrice));
                parameter.Add(new KeyValuePair <string, object>("@StoreID", aspxCommonObj.StoreID));
                parameter.Add(new KeyValuePair <string, object>("@PortalID", aspxCommonObj.PortalID));
                parameter.Add(new KeyValuePair <string, object>("@CultureName", aspxCommonObj.CultureName));
                parameter.Add(new KeyValuePair <string, object>("@AppointmentStatusID", obj.AppointmentStatusID));
                parameter.Add(new KeyValuePair <string, object>("@Title", obj.Title));
                parameter.Add(new KeyValuePair <string, object>("@FirstName", obj.FirstName));
                parameter.Add(new KeyValuePair <string, object>("@LastName", obj.LastName));
                parameter.Add(new KeyValuePair <string, object>("@Gender", obj.Gender));
                parameter.Add(new KeyValuePair <string, object>("@Mobile", obj.MobileNumber));
                parameter.Add(new KeyValuePair <string, object>("@Phone", obj.PhoneNumber));
                parameter.Add(new KeyValuePair <string, object>("@Email", obj.Email));
                parameter.Add(new KeyValuePair <string, object>("@PreferredDateID", obj.ServiceDateId));
                parameter.Add(new KeyValuePair <string, object>("@PreferredDate", obj.PreferredDate));
                parameter.Add(new KeyValuePair <string, object>("@PreferredTime", obj.PreferredTime));
                parameter.Add(new KeyValuePair <string, object>("@TypeOfTreatment", obj.TypeOfTreatment));
                parameter.Add(new KeyValuePair <string, object>("@StoreLocation", obj.StoreLocation));
                parameter.Add(new KeyValuePair <string, object>("@CustomerType", obj.TypeOfCustomer));
                parameter.Add(new KeyValuePair <string, object>("@MembershipElite", obj.MembershipElite));
                parameter.Add(new KeyValuePair <string, object>("@UserName", obj.FirstName));
                parameter.Add(new KeyValuePair <string, object>("@PaymentMethodID", obj.PaymentMethodID));
                parameter.Add(new KeyValuePair <string, object>("@PreferredTimeInterval", obj.PreferredTimeInterval));
                parameter.Add(new KeyValuePair <string, object>("@PreferredTimeID", obj.PreferredTimeId));
                parameter.Add(new KeyValuePair <string, object>("@EmployeeID", obj.EmployeeID));

                SQLHandler sqlh = new SQLHandler();
                sqlh.ExecuteNonQuery("[dbo].[usp_Aspx_AddAppointment]", parameter);

                if (appointmentId != 0 && obj.AppointmentStatusName.ToLower() == "completed")
                {
                    SendMailNotificatiion(aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName, obj);
                }
                else if (appointmentId == 0 && obj.AppointmentStatusName.ToLower() == "pending")
                {
                    SendMailNotificatiion(aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName, obj);
                }
                isSuccess = true;
            }
            catch (Exception)
            {
                isSuccess = false;
                // throw ex;
            }
            return(isSuccess);
        }
        public void SendMailNotificatiion(int storeId, int portalId, string cultureName, BookAppointmentInfo objInfo)
        {
            StoreSettingConfig ssc = new StoreSettingConfig();
            string logosrc = ssc.GetStoreSettingsByKey(StoreSetting.StoreLogoURL, storeId, portalId, cultureName);
            string name = "Appointment Approval - Email";
            List<KeyValuePair<string, object>> parameter = new List<KeyValuePair<string, object>>();
            parameter.Add(new KeyValuePair<string, object>("@PortalID", portalId));
            parameter.Add(new KeyValuePair<string, object>("@CultureName", cultureName));
            parameter.Add(new KeyValuePair<string, object>("@MessageTemplateTypeName", name));
            SQLHandler sql = new SQLHandler();

            int messageTemplateTypeId = sql.ExecuteNonQuery("[dbo].[usp_Aspx_GetMessageTemplateTypeID]", parameter, "@MessageTemplateID");
            MessageManagementController msgController = new MessageManagementController();
            var template = msgController.GetMessageTemplate(messageTemplateTypeId, portalId);

            string messageTemplate = template.Body;
            string src = HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + "/";

            string receiverEmailID = objInfo.Email;
            string subject = template.Subject;
            string senderEmail = template.MailFrom;
            var headerMsg = string.Empty;
            var customMessage = "";
            if (objInfo.AppointmentID > 0)
            {
                headerMsg = "status has been modified as follow.";
            }
            else if (objInfo.AppointmentID == 0)
            {
                headerMsg = "has been scheduled as following date and time.";
            }
            if (template != null)
            {
                string[] tokens = GetAllToken(messageTemplate);
                foreach (var token in tokens)
                {
                    switch (token)
                    {
                        case "%LogoSource%":
                            string imgSrc = src + logosrc;
                            messageTemplate = messageTemplate.Replace(token, imgSrc);
                            break;
                        case "%DateTime%":
                            messageTemplate = messageTemplate.Replace(token, DateTime.Now.ToString("MM/dd/yyyy"));
                            break;
                        case "%PreferredDate%":
                            messageTemplate = messageTemplate.Replace(token, objInfo.PreferredDate.ToString("MM/dd/yyyy"));
                            break;
                        case "%PreferredTime%":
                            messageTemplate = messageTemplate.Replace(token, objInfo.PreferredTime);
                            break;
                        case "%PreferredTimeInterval%":
                            messageTemplate = messageTemplate.Replace(token, objInfo.PreferredTimeInterval);
                            break;
                        case "%AppointmentStatus%":
                            messageTemplate = messageTemplate.Replace(token, objInfo.AppointmentStatusName);
                            break;
                        case "%ServerPath%":
                            messageTemplate = messageTemplate.Replace(token, src);
                            break;
                        case "%DateYear%":
                            messageTemplate = messageTemplate.Replace(token, System.DateTime.Now.Year.ToString());
                            break;
                        case "%AppointmentHeadingMessage%":
                            messageTemplate = messageTemplate.Replace(token, headerMsg);
                            break;
                        case "%AppointmentCustomMessage%":
                            messageTemplate = messageTemplate.Replace(token, customMessage);
                            break;
                        case "%ServiceProductName%":
                            messageTemplate = messageTemplate.Replace(token, objInfo.ServiceProductName);
                            break;
                    }
                }
            }

            SageFrameConfig pagebase = new SageFrameConfig();
            string emailSuperAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SuperUserEmail);
            string emailSiteAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SiteAdminEmailAddress);

            MailHelper.SendMailNoAttachment(senderEmail, receiverEmailID, subject, messageTemplate, emailSiteAdmin, emailSuperAdmin);
        }
        public bool SaveBookAppointment(int appointmentId, AspxCommonInfo aspxCommonObj, BookAppointmentInfo obj)
        {
            var isSuccess = false;
            try
            {
                List<KeyValuePair<string, object>> parameter = new List<KeyValuePair<string, object>>();
                parameter.Add(new KeyValuePair<string, object>("@AppointmentID", appointmentId));
                parameter.Add(new KeyValuePair<string, object>("@OrderID", obj.OrderID));
                parameter.Add(new KeyValuePair<string, object>("@ServiceCategoryID", obj.ServiceCategoryID));
                parameter.Add(new KeyValuePair<string, object>("@ServiceProductID", obj.ServiceProductID));
                parameter.Add(new KeyValuePair<string, object>("@ServiceProductPrice", obj.ServiceProductPrice));
                parameter.Add(new KeyValuePair<string, object>("@StoreID", aspxCommonObj.StoreID));
                parameter.Add(new KeyValuePair<string, object>("@PortalID", aspxCommonObj.PortalID));
                parameter.Add(new KeyValuePair<string, object>("@CultureName", aspxCommonObj.CultureName));
                parameter.Add(new KeyValuePair<string, object>("@AppointmentStatusID", obj.AppointmentStatusID));
                parameter.Add(new KeyValuePair<string, object>("@Title", obj.Title));
                parameter.Add(new KeyValuePair<string, object>("@FirstName", obj.FirstName));
                parameter.Add(new KeyValuePair<string, object>("@LastName", obj.LastName));
                parameter.Add(new KeyValuePair<string, object>("@Gender", obj.Gender));
                parameter.Add(new KeyValuePair<string, object>("@Mobile", obj.MobileNumber));
                parameter.Add(new KeyValuePair<string, object>("@Phone", obj.PhoneNumber));
                parameter.Add(new KeyValuePair<string, object>("@Email", obj.Email));
                parameter.Add(new KeyValuePair<string, object>("@PreferredDateID", obj.ServiceDateId));
                parameter.Add(new KeyValuePair<string, object>("@PreferredDate", obj.PreferredDate));
                parameter.Add(new KeyValuePair<string, object>("@PreferredTime", obj.PreferredTime));
                parameter.Add(new KeyValuePair<string, object>("@TypeOfTreatment", obj.TypeOfTreatment));
                parameter.Add(new KeyValuePair<string, object>("@StoreLocation", obj.StoreLocation));
                parameter.Add(new KeyValuePair<string, object>("@CustomerType", obj.TypeOfCustomer));
                parameter.Add(new KeyValuePair<string, object>("@MembershipElite", obj.MembershipElite));
                parameter.Add(new KeyValuePair<string, object>("@UserName", obj.FirstName));
                parameter.Add(new KeyValuePair<string, object>("@PaymentMethodID", obj.PaymentMethodID));
                parameter.Add(new KeyValuePair<string, object>("@PreferredTimeInterval", obj.PreferredTimeInterval));
                parameter.Add(new KeyValuePair<string, object>("@PreferredTimeID", obj.PreferredTimeId));
                parameter.Add(new KeyValuePair<string, object>("@EmployeeID", obj.EmployeeID));
	
                SQLHandler sqlh = new SQLHandler();
                sqlh.ExecuteNonQuery("[dbo].[usp_Aspx_AddAppointment]", parameter);

                if (appointmentId != 0 && obj.AppointmentStatusName.ToLower() == "completed")
                {
                    SendMailNotificatiion(aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName, obj);
                }
                else if (appointmentId == 0 && obj.AppointmentStatusName.ToLower() == "pending")
                {
                    SendMailNotificatiion(aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName, obj);
                }
                isSuccess = true;
            }
            catch (Exception)
            {
                isSuccess = false;
                // throw ex;

            }
            return isSuccess;
        }