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

            try
            {
                SetServiceSessionVariable("AppointmentCollection", obj);
                ServiceItemProvider objService = new ServiceItemProvider();
                objService.SaveBookAppointment(appointmentId, aspxCommonObj, obj);
                isSuccess = true;
            }
            catch (Exception)
            {
                isSuccess = false;
            }
            return(isSuccess);
        }
Esempio n. 2
0
    protected void SendConfrimMessage()
    {
        AspxCommerce.ServiceItem.BookAnAppointmentInfo appointmentInfo = new AspxCommerce.ServiceItem.BookAnAppointmentInfo();
        if (Session["OrderID"] != null)
        {
            int    storeID    = GetStoreID;
            int    portalID   = GetPortalID;
            string userName   = GetUsername;
            int    customerID = GetCustomerID;
            var    orderdata  = new OrderDetailsCollection();
            if (HttpContext.Current.Session["OrderCollection"] != null)
            {
                orderdata = (OrderDetailsCollection)HttpContext.Current.Session["OrderCollection"];
            }
            string invoice = orderdata.ObjOrderDetails.InvoiceNumber;
            lblInvoice.Text = invoice;

            var    random  = new Random();
            string transID = (random.Next(99999, 111111)).ToString();
            lblTransaction.Text = transID.Trim();

            if (Session["PaymentMethodName"] != null)
            {
                if (HttpContext.Current.Session["PaymentMethodName"].ToString() == "paypal")
                {
                    var pw = new PayPalWCFService();
                    int j  = orderdata.ObjOrderDetails.PaymentGatewayTypeID;
                    List <PayPalSettingInfo> setting = pw.GetAllPayPalSetting(j, storeID, portalID);
                    _authToken = setting[0].AuthToken;

                    _txToken = Request.QueryString.Get("tx");
                    _query   = string.Format("cmd=_notify-synch&tx={0}&at={1}", _txToken, _authToken);
                    const string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
                    const string strLive    = "https://www.paypal.com/cgi-bin/webscr";
                    string       test       = string.Empty;

                    if (Session["IsTestPayPal"] != null)
                    {
                        test = bool.Parse(Session["IsTestPayPal"].ToString()) ? strSandbox : strLive;
                    }
                    var req = (HttpWebRequest)WebRequest.Create(test);

                    req.Method        = "POST";
                    req.ContentType   = "application/x-www-form-urlencoded";
                    req.ContentLength = _query.Length;

                    var stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
                    stOut.Write(_query);
                    stOut.Close();

                    var stIn = new StreamReader(req.GetResponse().GetResponseStream());
                    _strResponse = stIn.ReadToEnd();
                    stIn.Close();

                    if (_strResponse.StartsWith("SUCCESS"))
                    {
                        string sessionCode = HttpContext.Current.Session.SessionID;
                        try
                        {
                            PayPalHandler pdtt = ParseAfterIPN(_strResponse, storeID, portalID, userName, customerID, sessionCode, TemplateName, _addressPath);
                        }
                        catch (Exception)
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentParsingIPNError");
                        }

                        String[] stringArray = _strResponse.Split('\n');
                        int      i;
                        string   status = string.Empty;
                        for (i = 1; i < stringArray.Length - 1; i++)
                        {
                            String[] stringArray1 = stringArray[i].Split('=');

                            String sKey   = stringArray1[0];
                            String sValue = HttpUtility.UrlDecode(stringArray1[1]);

                            switch (sKey)
                            {
                            case "txn_id":
                                _transID = Convert.ToString(sValue);
                                break;

                            case "payment_status":
                                status = Convert.ToString(sValue);
                                break;
                            }
                        }
                        lblTransaction.Text = _transID.Trim();
                        //lblInvoice.Text = _invoice;
                        lblPaymentMethod.Text = "Paypal";
                        if (status.ToLower().Trim() == "completed")
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                        }
                        else if (status.ToLower().Trim() == "pending")
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentPending");
                        }
                    }
                    else
                    {
                        lblerror.Text = GetSageMessage("Payment", "PaymentError");
                    }
                }
                else if (HttpContext.Current.Session["PaymentMethodName"].ToString().ToLower() == "cashondelivery")
                {
                    const int responseCode = 1;                    const string responsereasontext = "Transaction occured successfully";
                    const int responsereasonCode = 1;

                    string purchaseorderNo = (random.Next(0, 1000)).ToString();
                    string sessionCode     = HttpContext.Current.Session.SessionID;
                    string result          = Parse(transID, invoice, purchaseorderNo, responseCode, responsereasonCode, responsereasontext, storeID, portalID, userName, customerID, sessionCode);
                    lblerror.Text = result;
                    lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                    var tinfo = new TransactionLogInfo();
                    var tlog  = new TransactionLog();
                }
            }
            else
            {
                Response.Redirect(_sageRedirectPath, false);
            }
            if (HttpContext.Current.Session["AppointmentCollection"] != null)
            {
                appointmentInfo = (AspxCommerce.ServiceItem.BookAnAppointmentInfo)HttpContext.Current.Session["AppointmentCollection"];
            }

            lblServiceName.Text         = appointmentInfo.ServiceCategoryName.Trim();
            lblServiceProduct.Text      = appointmentInfo.ServiceProductName;
            lblServiceDuration.Text     = appointmentInfo.ServiceDuration;
            lblStoreLocation.Text       = appointmentInfo.StoreLocationName;
            lblServiceProviderName.Text = appointmentInfo.EmployeeName;
            lblProductPrice.Text        = appointmentInfo.ServiceProductPrice.Trim();

            lblPaymentMethod.Text = appointmentInfo.PaymentMethodName;
            lblDate.Text          = appointmentInfo.PreferredDate.ToString("MM/dd/yyyy");
            lblTime.Text          = appointmentInfo.PreferredTimeInterval.Trim();
        }
    }
        public bool SaveBookAppointment(int appointmentId, AspxCommonInfo aspxCommonObj, BookAnAppointmentInfo obj)
        {
            bool isSuccess = false;

            try
            {
                List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPC(aspxCommonObj);
                parameter.Add(new KeyValuePair <string, object>("AppointmentID", (object)appointmentId));
                parameter.Add(new KeyValuePair <string, object>("OrderID", (object)obj.OrderID));
                parameter.Add(new KeyValuePair <string, object>("ServiceCategoryID", (object)obj.ServiceCategoryID));
                parameter.Add(new KeyValuePair <string, object>("ServiceProductID", (object)obj.ServiceProductID));
                parameter.Add(new KeyValuePair <string, object>("ServiceProductPrice", obj.ServiceProductPrice));
                parameter.Add(new KeyValuePair <string, object>("AppointmentStatusID", (object)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", (object)obj.ServiceDateId));
                parameter.Add(new KeyValuePair <string, object>("PreferredDate", (object)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.UserName));
                parameter.Add(new KeyValuePair <string, object>("PaymentMethodID", (object)obj.PaymentMethodID));
                parameter.Add(new KeyValuePair <string, object>("PreferredTimeInterval", obj.PreferredTimeInterval));
                parameter.Add(new KeyValuePair <string, object>("PreferredTimeID", (object)obj.PreferredTimeId));
                parameter.Add(new KeyValuePair <string, object>("EmployeeID", (object)obj.EmployeeID));
                (new OracleHandler()).ExecuteNonQuery("usp_Aspx_AddAppointment", parameter);
                if (!(appointmentId == 0 ? true : !(obj.AppointmentStatusName.ToLower() == "completed")))
                {
                    this.SendMailNotificatiion(aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName, obj);
                }
                else if ((appointmentId != 0 ? false : obj.AppointmentStatusName.ToLower() == "pending"))
                {
                    this.SendMailNotificatiion(aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName, obj);
                }
                isSuccess = true;
            }
            catch (Exception exception)
            {
                isSuccess = false;
            }
            return(isSuccess);
        }
        public void SendMailNotificatiion(int storeId, int portalId, string cultureName, BookAnAppointmentInfo objInfo)
        {
            DateTime           now;
            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> >()
            {
                new KeyValuePair <string, object>("PortalID", (object)portalId),
                new KeyValuePair <string, object>("CultureName", cultureName),
                new KeyValuePair <string, object>("MessageTemplateTypeName", name)
            };
            int messageTemplateTypeId      = (new OracleHandler()).ExecuteNonQuery("usp_Aspx_GetMessageTemplateTypeID", parameter, "MessageTemplateID");
            MessageManagementInfo template = (new MessageManagementController()).GetMessageTemplate(messageTemplateTypeId, portalId);
            string messageTemplate         = template.Body;
            string src             = string.Concat(HttpContext.Current.Request.ServerVariables["SERVER_NAME"], "/");
            string receiverEmailID = objInfo.Email;
            string subject         = template.Subject;
            string senderEmail     = template.MailFrom;
            string headerMsg       = string.Empty;
            string 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[] allToken = this.GetAllToken(messageTemplate);
                for (int i = 0; i < (int)allToken.Length; i++)
                {
                    string token = allToken[i];
                    string str   = token;
                    if (str != null)
                    {
                        switch (str)
                        {
                        case "%LogoSource%":
                        {
                            string imgSrc = string.Concat(src, logosrc);
                            messageTemplate = messageTemplate.Replace(token, imgSrc);
                            break;
                        }

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

                        case "%PreferredDate%":
                        {
                            now             = objInfo.PreferredDate;
                            messageTemplate = messageTemplate.Replace(token, now.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%":
                        {
                            int year = DateTime.Now.Year;
                            messageTemplate = messageTemplate.Replace(token, 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);
        }
    protected void SendConfrimMessage()
    {

        AspxCommerce.ServiceItem.BookAnAppointmentInfo appointmentInfo = new AspxCommerce.ServiceItem.BookAnAppointmentInfo();
        if (Session["OrderID"] != null)
        {
            int storeID = GetStoreID;
            int portalID = GetPortalID;
            string userName = GetUsername;
            int customerID = GetCustomerID;
            var orderdata = new OrderDetailsCollection();
            if (HttpContext.Current.Session["OrderCollection"] != null)
            {
                orderdata = (OrderDetailsCollection) HttpContext.Current.Session["OrderCollection"];
            }
            string invoice = orderdata.ObjOrderDetails.InvoiceNumber;
            lblInvoice.Text = invoice;

            var random = new Random();
            string transID = (random.Next(99999, 111111)).ToString();
            lblTransaction.Text = transID.Trim();

            if (Session["PaymentMethodName"] != null)
            {
                if (HttpContext.Current.Session["PaymentMethodName"].ToString() == "paypal")
                {
                    var pw = new PayPalWCFService();
                    int j = orderdata.ObjOrderDetails.PaymentGatewayTypeID;
                    List<PayPalSettingInfo> setting = pw.GetAllPayPalSetting(j, storeID, portalID);
                    _authToken = setting[0].AuthToken;

                    _txToken = Request.QueryString.Get("tx");
                    _query = string.Format("cmd=_notify-synch&tx={0}&at={1}", _txToken, _authToken);
                                                          const string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
                    const string strLive = "https://www.paypal.com/cgi-bin/webscr";
                    string test = string.Empty;

                    if (Session["IsTestPayPal"] != null)
                    {

                        test = bool.Parse(Session["IsTestPayPal"].ToString()) ? strSandbox : strLive;
                    }
                    var req = (HttpWebRequest) WebRequest.Create(test);

                                       req.Method = "POST";
                    req.ContentType = "application/x-www-form-urlencoded";
                    req.ContentLength = _query.Length;

                                       var stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
                    stOut.Write(_query);
                    stOut.Close();

                                       var stIn = new StreamReader(req.GetResponse().GetResponseStream());
                    _strResponse = stIn.ReadToEnd();
                    stIn.Close();

                                       if (_strResponse.StartsWith("SUCCESS"))
                    {
                        string sessionCode = HttpContext.Current.Session.SessionID;
                                                                                             try
                        {
                            PayPalHandler pdtt = ParseAfterIPN(_strResponse, storeID, portalID, userName, customerID, sessionCode, TemplateName, _addressPath);

                        }
                        catch (Exception)
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentParsingIPNError");
                        } 

                        String[] stringArray = _strResponse.Split('\n');
                        int i;
                        string status = string.Empty;
                        for (i = 1; i < stringArray.Length - 1; i++)
                        {
                            String[] stringArray1 = stringArray[i].Split('=');

                            String sKey = stringArray1[0];
                            String sValue = HttpUtility.UrlDecode(stringArray1[1]);

                                                       switch (sKey)
                            {
                                case "txn_id":
                                    _transID = Convert.ToString(sValue);
                                    break;
                                case "payment_status":
                                    status = Convert.ToString(sValue);
                                    break;
                            }
                        }
                        lblTransaction.Text = _transID.Trim();
                        //lblInvoice.Text = _invoice;
                        lblPaymentMethod.Text = "Paypal";
                        if (status.ToLower().Trim() == "completed")
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                        }
                        else if (status.ToLower().Trim() == "pending")
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentPending");
                        }
                    }
                    else
                    {
                        lblerror.Text = GetSageMessage("Payment", "PaymentError");
                    }
                }
                else if (HttpContext.Current.Session["PaymentMethodName"].ToString().ToLower() == "cashondelivery")
                {
                    const int responseCode = 1;                    const string responsereasontext = "Transaction occured successfully";
                    const int responsereasonCode = 1;
                   
                    string purchaseorderNo = (random.Next(0, 1000)).ToString();
                                                string sessionCode = HttpContext.Current.Session.SessionID;
                    string result = Parse(transID, invoice, purchaseorderNo, responseCode, responsereasonCode, responsereasontext, storeID, portalID, userName, customerID, sessionCode);
                    lblerror.Text = result;
                    lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                    var tinfo = new TransactionLogInfo();
                    var tlog = new TransactionLog();  
                }
            }
            else
            {
                Response.Redirect(_sageRedirectPath, false);
            }
            if (HttpContext.Current.Session["AppointmentCollection"] != null)
            {

                appointmentInfo = (AspxCommerce.ServiceItem.BookAnAppointmentInfo)HttpContext.Current.Session["AppointmentCollection"];

            }

            lblServiceName.Text = appointmentInfo.ServiceCategoryName.Trim();
            lblServiceProduct.Text = appointmentInfo.ServiceProductName;
            lblServiceDuration.Text = appointmentInfo.ServiceDuration;
            lblStoreLocation.Text = appointmentInfo.StoreLocationName;
            lblServiceProviderName.Text = appointmentInfo.EmployeeName;
            lblProductPrice.Text = appointmentInfo.ServiceProductPrice.Trim();

            lblPaymentMethod.Text = appointmentInfo.PaymentMethodName;
            lblDate.Text =  appointmentInfo.PreferredDate.ToString("MM/dd/yyyy");
            lblTime.Text = appointmentInfo.PreferredTimeInterval.Trim();
        }
    }
    public bool SaveBookAppointment(int appointmentId, AspxCommonInfo aspxCommonObj,  BookAnAppointmentInfo obj)
    {
        try
        {          
            ServiceItemController objService = new ServiceItemController();
            bool isSave = objService.SaveBookAppointment(appointmentId, aspxCommonObj, obj);
            return isSave;
        }
        catch (Exception)
        {
            return false;

        }
    }    
        public void SendMailNotificatiion(int storeId, int portalId, string cultureName,  BookAnAppointmentInfo 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,  BookAnAppointmentInfo obj)//upto this 1/13/2013
        {
            var isSuccess = false;
            try
            {
                List<KeyValuePair<string, object>> parameter = CommonParmBuilder.GetParamSPC(aspxCommonObj);
                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>("@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.UserName));
                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 bool SaveBookAppointment(int appointmentId, AspxCommonInfo aspxCommonObj, BookAnAppointmentInfo obj)
        {
            var isSuccess = false;
            try
            {
                SetServiceSessionVariable("AppointmentCollection",obj);
                ServiceItemProvider objService = new ServiceItemProvider();
                objService.SaveBookAppointment(appointmentId, aspxCommonObj, obj);
                isSuccess = true;
            }
            catch (Exception)
            {
                isSuccess = false;

            }
            return isSuccess;
        }
        public void SendMailNotificatiion(int storeId, int portalId, string cultureName, BookAnAppointmentInfo 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, BookAnAppointmentInfo obj) //upto this 1/13/2013
        {
            var isSuccess = false;

            try
            {
                List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPC(aspxCommonObj);
                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>("@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.UserName));
                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);
        }