예제 #1
0
        public ActionResult CustUpdateProfile()
        {
            int id = int.Parse(Session["LoginUser"].ToString());
            ChemAnalystContext   _context = new ChemAnalystContext();
            CustomerDataStore    Obj      = new CustomerDataStore();
            SA_Customer          obj      = Obj.GetCustomerByid(id);
            SA_CustomerViewModel Objuser  = new SA_CustomerViewModel();

            Objuser.id           = obj.id;
            Objuser.Fname        = obj.Fname;
            Objuser.Lname        = obj.Lname;
            Objuser.Phone        = obj.Phone;
            Objuser.Role         = obj.Role;
            Objuser.Email        = obj.Email;
            Objuser.Gender       = obj.Gender;
            Objuser.UserPassword = obj.UserPassword;
            Objuser.ProfileImage = obj.ProfileImage;

            var customerData = (from User in _context.SA_Role
                                //  select  { Fname = User.Fname+" "+User.Lname , Phone = User.Phone, Role=User.Role,Email=User.Email,UserPassword=User.Password});
                                select new SelectListItem {
                Text = User.Role, Value = User.Role
            }).ToList();

            Objuser.UserRoleList = customerData;
            return(View("cust-update-profile", Objuser));
        }
예제 #2
0
        public static string ValidateMail()
        {
            try
            {
                var emailaddress = Console.ReadLine();
                var value        = CustomerDataStore.EmailExists(emailaddress);


                if (Regex.IsMatch(emailaddress, @"^[^@\s\.]+@[^@\s]+\.[^@\s]+$") && value)
                {
                    return(emailaddress);
                }
                else
                {
                    throw new FormatException("The mail you entered is invalid");
                }
            }

            catch (FormatException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Please enter a valid email");
                return(ValidateMail());
            }
        }
        public ActionResult ForgotPassword(string Username)
        {
            try
            {
                CustomerDataStore ObjUser   = new CustomerDataStore();
                SA_Customer       loginUser = ObjUser.GetCustomerByEmail(Username);
                if (loginUser == null)
                {
                    TempData["ErrorMessage"] = "User does not exist.";
                    return(View());
                }
                //string strEncryptedCurr = (Helpers.Encrypt(CurPassword));
                string strDecryptedCurr = (Helpers.Decrypt(loginUser.UserPassword));


                string EmailBody = SubscriptionDAL.GetHtml("ContactUs.html");
                EmailBody = EmailBody.Replace("#Password", strDecryptedCurr);

                SubscriptionDAL.SendMail("Chem Analyst", "info@chemanalyst", Username, "CONTACT US", EmailBody, "*****@*****.**");
                TempData["ErrorMessage"] = "Password sent on your email address.";
                return(View());
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = "Error" + ex.ToString();
                return(View());
            }
        }
        public static void RegisterCustomer()
        {
            var _customerInstance = ClassNewers.CustomerCreator();

            bool active = false;

            while (!active)
            {
                Helper1.Logger("Enter your email Address");
                _customerInstance.EmailAddress = Validate.ValidateMail();

                Helper1.Logger("Enter your FirstName");
                _customerInstance.FirstName = Validate.ValidateName();

                Helper1.Logger("Enter your LastName");
                _customerInstance.LastName = Helper1.Reader();

                Helper1.Logger("Enter your Password");;
                _customerInstance.Password = Validate.ValidatePassword();

                CustomerDataStore.SaveCustomer(_customerInstance);
                RegisterAccountInitial(_customerInstance);
                active = true;

                Console.Clear();
            }
        }
 public Repository()
 {
     using (var db = new CustomerDataStore())
     {
         this.customers = db.Customers.Select(c => c).ToList <Customer>();
         this.gadgets   = db.Gadgets.Select(g => g).ToList <Gadget>();
     }
 }
예제 #6
0
        public static void CustomerLogger()
        {
            Console.Clear();
            bool active = false;

            while (!active)
            {
                //Checks that the Databse is not empty before allowing any user access to log-in.
                if (CustomerDataStore.DataStoreCount())
                {
                    CustomerDetails foundUser = null;
                    Helper1.Logger("Please enter your log-in details");

                    Helper1.Logger("Please enter your registered email Address");
                    var Login_mail = Helper1.Reader();

                    Helper1.Logger("Please enter your password");
                    var Login_password = Helper1.Reader();

                    //Checks to see that the user attempting to log-in actually exists in the Database
                    var user1 = CustomerDataStore.FindCustomerByMail(Login_mail);
                    var user2 = CustomerDataStore.FindCustomerByPassword(Login_password);
                    if (user1 != null && user2 != null && user1 == user2)
                    {
                        Helper1.Logger("Welcome you are logged in");
                        Helper1.Reader();
                        foundUser = user1;

                        MainUserInterface.ActivityPage(foundUser);
                        active = true;
                    }
                    else
                    {
                        Console.WriteLine("Sorry, this user does not exist in our database");
                        Console.ReadKey();
                        active = true;
                    }
                }
                else
                {
                    Console.WriteLine("There are currently no users in the database. Rgister first");
                    Console.ReadKey();
                    active = true;
                }
                break;
            }
        }
예제 #7
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());
        }
예제 #8
0
        public ActionResult UpdatePassword(FormCollection ChangePassword)
        {
            int    LoginUser     = int.Parse(ChangePassword["LoginUser"]);
            string CurPassword   = ChangePassword["CurPassword"];
            string newPassword   = ChangePassword["newPassword"];
            string confirmpasswd = ChangePassword["confirmpasswd"];

            //string strPassword = "******";

            string strEncryptedCurr = (Helpers.Encrypt(CurPassword));
            string strDecryptedCurr = (Helpers.Decrypt(strEncryptedCurr));

            string strEncrypted = (Helpers.Encrypt(newPassword));
            string strDecrypted = (Helpers.Decrypt(strEncrypted));

            CustomerDataStore ObjUser   = new CustomerDataStore();
            SA_Customer       loginUser = ObjUser.GetCustomerByid(LoginUser);

            if ((loginUser != null))
            {
                if (loginUser.UserPassword == strEncryptedCurr)
                {
                    loginUser.id           = LoginUser;
                    loginUser.UserPassword = strEncrypted;
                    int valid = ObjUser.UpdatePassword(loginUser);
                    if (valid > 0)
                    {
                        ViewBag.Message = "Password Updated Successfuly.";
                    }
                    else
                    {
                        ViewBag.Message = "Password not Updated Successfuly.";
                    }
                }
                else
                {
                    ViewBag.Message = "Your current Password is not matched.";
                }
            }
            return(View("custChangePassword"));
        }
예제 #9
0
        public ActionResult CustSaveProfile(SA_Customer User)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    var path = Path.Combine(Server.MapPath("~/images"), fileName);
                    file.SaveAs(path);
                    User.ProfileImage = fileName;
                }
            }
            CustomerDataStore Obj = new CustomerDataStore();

            Obj.UpdateCustomer(User);

            return(RedirectToAction("CustUpdateProfile", "Login"));
        }
예제 #10
0
        async Task ExecuteLoadCustomersCommand()
        {
            IsBusy = true;

            try
            {
                Customers.Clear();
                var _persons = await CustomerDataStore.GetItemsAsync(true);

                foreach (var _person in _persons)
                {
                    Customers.Add(_person);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        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 }));
        }