예제 #1
0
        public ActionResult InquiryForm(InquiryVM eq)
        {
            Emailsending objEmailsending = new Emailsending();
            var          response        = Request["g-recaptcha-response"];
            var          catptchastatus  = false;
            string       secreatekey     = "6LdU_nUUAAAAAD6JiuKTysnVW6Aa4D5SU0z1Fl4u";
            var          client          = new WebClient();
            string       resstring       = string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secreatekey, response);
            var          result          = client.DownloadString(resstring);

            if (result.ToLower().Contains("false"))
            {
                catptchastatus = false;
            }
            else
            {
                catptchastatus = true;
            }
            // ViewBag.Message = status ? "Google recaptcha validation success" : "Google recaptcha validation fails";
            CustomerInquiry e        = new CustomerInquiry();
            var             Formname = string.Empty;
            int             FormTypeId;
            string          Publisher = string.Empty;

            if (catptchastatus == true)
            {
                if (ModelState.IsValid)
                {
                    // cap = Session["Captcha"].ToString();
                    cap = ExcellentMarketResearch.Areas.Admin.Models.Common.Decrypt(eq.RealCaptcha);

                    if (eq.ReportId > 0)
                    {
                        var Publish = (from l in db.ReportMasters
                                       join p in db.PublisherMasters on l.PublishereId equals p.PublisherId
                                       where l.ReportId == eq.ReportId
                                       select p).FirstOrDefault();
                        Publisher = Publish.PublisherName;
                    }
                    else
                    {
                        Publisher = "!";
                    }

                    //if (eq.CaptchaCode == cap)
                    //{
                    CustomerInquiry cst       = new CustomerInquiry();
                    var             IpAddress = ExcellentMarketResearch.Models.PaymentGateway.IPAddress.GetIPAddress();
                    cst.Company         = eq.Company;
                    cst.Country         = eq.Country;
                    cst.CustomerMessage = eq.CustomerMessage;
                    cst.Designation     = eq.Designation;
                    cst.EmailId         = eq.EmailId;
                    cst.Name            = eq.Name;
                    eq.AreaCode        += "-" + eq.PhoneNumber;
                    cst.PhoneNumber     = eq.AreaCode;
                    cst.ReportId        = eq.ReportId;
                    cst.CaptchaCode     = eq.CaptchaCode;
                    cst.FormType        = eq.FormType;
                    cst.CaptchaCode     = "121321";
                    if (eq.FormType == "InquiryForm")
                    {
                        Formname   = "Inquiry";
                        FormTypeId = 1;
                    }
                    else if (eq.FormType == "SampleRequestForm")
                    {
                        Formname   = "Request Sample";
                        FormTypeId = 2;
                    }
                    else if (eq.FormType == "ContactUs")
                    {
                        FormTypeId = 4;
                    }
                    else
                    {
                        // Checkout page

                        FormTypeId = 3;
                    }

                    try
                    {
                        db.CustomerInquiries.Add(cst);
                        //db.Entry(cst).State = EntityState.Added;
                        db.SaveChanges();

                        // QYGroupRepository.PaymentGateway.Emailsending objEmailsending = new QYGroupRepository.PaymentGateway.Emailsending();
                        // string ipAddress = QYGroupRepository.PaymentGateway.IPAddress.GetIPAddress();
                        // Task.Run(() => new CRMWebService.WebServiceSoapClient().InsertUpdateKey(0, eq.ReportId, eq.ReportTitle, FormTypeId, 34, 1, 1, eq.ReportUrl, ipAddress, eq.Name, eq.EmailId, eq.AreaCode, eq.Company, eq.Designation, "!", "!", eq.Country, "!", eq.CustomerMessage, 1, "!", "!", "!", Publisher, 38, "BW&Zk^HfZ44P339nEzqrrawY4HL_VXw-5f+%8b4Hdw?$?m$G*!+kCGLK%3JjDn-74NY*LyhdJr6RAte&8MBWy6F2j82+qn7ap&DB@z-*q3sdH*#D-kwACucyaM7vzet4pSa?m^xnP@3zN5K9=*L6WLpDurTSuVTR3Hd&3XLHJnCcR!h*dL#fQhp^*#25LEFrMTt@z&8RWdf^CQcj!QrQU^WkdC5$Ub$8qnu!g7?*$$4%%M9?8spAugyCzZg5@dLGBNS_^7?x3VczR75J&=+9yFDVg*Qpd@R^_Jz-GtWgHxv4Kf$=2pxT@bqhx%aqgzZAN6RzZZ%rNX7km3fu$h?Z=+V3b_MQPLAxJBVT!=Ta+7Xd?CF3#4w44L@HU%nf4m#y-d2vgn6Gp2t7w!qFY%kN#y6DNAy#TbrZnqnjMtgeAd%BHSm9H29z4G_?qnBHE5J2EyutZ2RSh?P2fUE-sF8bNFdre@G^qQ??JzJuDCT3hby2py#+yfg*jC%&YBkrutHs"));

                        //Auto Mailer
                        Task.Run(() => objEmailsending.SendEmail("*****@*****.**", "Sales", cst.EmailId, "", "*****@*****.**", "excellentmarketresearch.com : " + eq.ReportTitle, objEmailsending.GenerateMailBody_RequestSample_AutoReply(cst.Name, eq.ReportTitle)));

                        //To company
                        // Task.Run(() => objEmailsending.SendEmail("*****@*****.**", "Sales", "*****@*****.**", "", "", "ExcellentMarketResearch.com" + " : " + Formname,objEmailsending.GenerateMailBody_RequestSample(eq.ReportTitle, cst.Name, cst.EmailId, cst.PhoneNumber, cst.Company, cst.Country, cst.Designation, cst.CustomerMessage)));
                        Task.Run(() => objEmailsending.SendEmail("*****@*****.**", "Sales", "*****@*****.**", "", "", "excellentMarketResearch.com" + " : " + Formname, objEmailsending.GenerateMailBody_RequestSample(eq.ReportTitle, cst.Name, cst.EmailId, cst.PhoneNumber, cst.Company, cst.Country, cst.Designation, cst.CustomerMessage, IpAddress)));

                        Session["Name"] = cst.Name;

                        return(RedirectToAction("Index", "InquiryForm", new { reporrtid = cst.ReportId }));
                    }
                    catch (DbEntityValidationException dbEx)
                    {
                        foreach (var validationErrors in dbEx.EntityValidationErrors)
                        {
                            foreach (var validationError in validationErrors.ValidationErrors)
                            {
                                System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                            }
                        }
                    }
                    //}
                    //Return the if model not valid
                    return(View(eq));
                }
                return(View(eq));
            }
            return(View(eq));
        }
예제 #2
0
        public ActionResult Index(ContactUsVM eq)
        {
            InquiryVM    e = new InquiryVM();
            Emailsending objEmailsending = new Emailsending();
            var          response        = Request["g-recaptcha-response"];
            var          catptchastatus  = false;
            string       secreatekey     = "6LdU_nUUAAAAAD6JiuKTysnVW6Aa4D5SU0z1Fl4u";
            var          client          = new WebClient();
            string       resstring       = string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secreatekey, response);
            var          result          = client.DownloadString(resstring);

            if (result.ToLower().Contains("false"))
            {
                catptchastatus = false;
            }
            else
            {
                catptchastatus = true;
            }

            //int FormTypeId=4;
            string Publisher = string.Empty;

            if (catptchastatus)
            {
                if (ModelState.IsValid)
                {
                    // cap = Session["Captcha"].ToString();
                    var cap = ExcellentMarketResearch.Areas.Admin.Models.Common.Decrypt(eq.RealCaptcha);

                    Publisher = "!";

                    if (eq.CaptchaCode == cap)
                    {
                        CustomerInquiry cst = new CustomerInquiry();

                        cst.CustomerMessage = eq.CustomerMessage;
                        cst.EmailId         = eq.EmailId;
                        cst.Name            = eq.Name;
                        // eq.AreaCode += "-" + eq.PhoneNumber;
                        cst.PhoneNumber = eq.PhoneNumber;
                        cst.ReportId    = eq.ReportId;
                        cst.Country     = eq.Country;
                        cst.CaptchaCode = eq.CaptchaCode;

                        string ReportTitle = string.Empty;
                        string ReportUrl   = string.Empty;

                        try
                        {
                            db.CustomerInquiries.Add(cst);
                            //db.Entry(cst).State = EntityState.Added;

                            db.SaveChanges();

                            //  QYGroupRepository.PaymentGateway.Emailsending objEmailsending = new QYGroupRepository.PaymentGateway.Emailsending();



                            //Auto Mailer
                            objEmailsending.SendEmail("*****@*****.**", "Sales", cst.EmailId, "", "", "ExcellentMarketResearch.com  : ContactUs" + " ", GenerateMailBody_ContactUs_AutoReply(cst.Name, ReportTitle));

                            //To company
                            objEmailsending.SendEmail("*****@*****.**", "Sales", "[email protected],", "", "*****@*****.**", "ExcellentMarketResearch.com " + " : " + "Contact Us", GenerateMailBody_ContactUs(ReportTitle, cst.Name, cst.EmailId, cst.PhoneNumber, "!", "!", "!", cst.CustomerMessage));

                            Session["Name"] = cst.Name;

                            return(RedirectToAction("ContactusThanks", "ContactUs"));
                            //return RedirectToRoute(new
                            //{
                            //    controller = "InquiryForm",
                            //    action = "Index",
                            //    reporrtid = cst.ReportId
                            //});
                        }
                        catch (DbEntityValidationException dbEx)
                        {
                            foreach (var validationErrors in dbEx.EntityValidationErrors)
                            {
                                foreach (var validationError in validationErrors.ValidationErrors)
                                {
                                    System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                                }
                            }
                        }
                    }
                    //Return the if model not valid
                    return(View());
                }
            }


            return(View(eq));
        }