Example #1
0
        public ActionResult Custlogin(FormCollection collection)
        {
            CustWiseAccessDataStore Obj   = new CustWiseAccessDataStore();
            SA_Customer             login = new SA_Customer();

            login.Email = Request["Username"];

            login.UserPassword = Request["Password"];

            string strEncrypted = (Helpers.Encrypt(login.UserPassword));
            string strDecrypted = (Helpers.Decrypt(strEncrypted));

            login.UserPassword = strEncrypted;

            CustomerDataStore LoginStore = new CustomerDataStore();
            SA_Customer       objectuser = LoginStore.CheckCustomer(login);

            if (objectuser != null)
            {
                if (LoginStore.CheckCustomerPackage(login))
                {
                    TempData["ErrorMessage"] = "Your subscription expired.";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    Session["LoginUser"] = objectuser.id;
                    Session["User"]      = objectuser.Fname + " " + objectuser.Lname;
                    Session["UserImg"]   = "images/" + "user.jpg";
                    Session["UserRole"]  = objectuser.Role;
                    List <CustWiseAccess> Access = Obj.GetCustpage(objectuser.id);
                    Session["Access"] = Access;
                    return(View());
                }
            }
            else
            {
                TempData["ErrorMessage"] = "Invalid credentials.";
                return(RedirectToAction("Index"));
            }
            return(View());
        }
        public async Task <ActionResult> SaveSalesPackageSubscriptionAsync(SalesPackageSubscription subs)
        {
            bool              result = false;
            LeadDAL           l      = new LeadDAL();
            CustomerDataStore c      = new CustomerDataStore();
            var lst = l.GetLeadByid(subs.LeadId);

            //string strPassword = "******";
            string strPassword  = "******";
            string strEncrypted = (Helpers.Encrypt(strPassword));
            string strDecrypted = (Helpers.Decrypt(strEncrypted));

            try
            {
                subs.CreatedDate = DateTime.Now;
                CustWiseAccessDataStore DAL   = new CustWiseAccessDataStore();
                CustomerDataStore       Check = new CustomerDataStore();
                SubscriptionDAL         Obj   = new SubscriptionDAL();
                if (ModelState.IsValid)
                {
                    if (Check.CheckCustomerCount(lst.CorpEmail, strEncrypted) == 0)
                    {
                        SA_Customer Customer = new SA_Customer();
                        Customer.MenuId       = subs.Id.ToString();
                        Customer.Email        = lst.CorpEmail;
                        Customer.Phone        = lst.Phone;
                        Customer.UserPassword = strEncrypted;
                        Customer.Role         = "Customer";
                        Customer.ProfileImage = "";
                        Customer.Fname        = lst.Name;
                        Customer.Lname        = "";

                        c.AddCustomer(Customer);

                        subs.UserId = Customer.id;
                        result      = await Obj.AddSalesPackageTrial(subs);

                        DAL.AddCustWiseAccess(subs.MenuId, Customer.id);
                        DAL.AddCustProduct(subs.ProductId, Customer.id, subs.MenuId);

                        string EmailBody = SubscriptionDAL.GetHtml("PackageWelcome.html");
                        //EmailBody = EmailBody.Replace("@Name@", Customer.Fname + " " + Customer.Lname);
                        EmailBody = EmailBody.Replace("@Pass@", "1234");
                        EmailBody = EmailBody.Replace("@Email@", Customer.Email);
                        //EmailBody = EmailBody.Replace("@SiteRoot@", CommonUtility.SitePath);
                        //EmailBody = EmailBody.Replace("@URL@", CommonUtility.SitePath);

                        SubscriptionDAL.SendMail("Chem Analyst", "info@chemanalyst", Customer.Email, "Package Activation", EmailBody, "*****@*****.**");

                        UpdateLeadStatus(subs.LeadId);
                    }
                    else
                    {
                        var custId = c.GetCustomerList().Where(w => w.Email == lst.CorpEmail).FirstOrDefault().id;
                        subs.UserId = custId;
                        result      = await Obj.AddSalesPackageTrial(subs);

                        DAL.AddCustWiseAccess(subs.MenuId, custId);
                        DAL.AddCustProduct(subs.ProductId, custId, subs.MenuId);

                        return(Json(new { result = "One more package added successfully.", JsonRequestBehavior.AllowGet }));
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(new { result = "Data Added Successfully", JsonRequestBehavior.AllowGet }));
        }