Exemplo n.º 1
0
        public ActionResult Create(CustomerDetali customer)
        {
            if (ModelState.IsValid)
            {
                CustomerDetali detali = new CustomerDetali();

                bool detalinew = informationDetailsEntities.CustomerDetalis.Any(x => x.CustomerName == customer.CustomerName);
                if (detalinew)
                {
                    //ViewBag.CustomerName = "CustomerName is allrady in database";
                    ModelState.AddModelError("CustomerName", "CustomerName is allrady in database");
                }

                else
                {
                    detali.CustomerName    = customer.CustomerName;
                    detali.Email           = customer.Email;
                    detali.Phone           = customer.Phone;
                    detali.CustomerAddress = customer.CustomerAddress;
                    detali.City            = customer.City;
                    detali.images          = customer.images;
                    informationDetailsEntities.CustomerDetalis.Add(detali);
                    informationDetailsEntities.SaveChanges();
                    return(RedirectToAction("GetDetails"));
                }
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Registration(UserLogin userLogin)
        {
            if (ModelState.IsValid)
            {
                UserLogin detali = new UserLogin();

                bool detalinew = informationDetailsEntities.UserLogins.Any(x => x.Fullname == userLogin.Fullname);
                if (detalinew)
                {
                    //ViewBag.CustomerName = "CustomerName is allrady in database";
                    ModelState.AddModelError("CustomerName", "CustomerName is allrady in database");
                }
                else
                {
                    detali.Fullname     = userLogin.Fullname;
                    detali.EmailAddress = userLogin.EmailAddress;
                    detali.password     = Crypto.Hash(userLogin.password);

                    informationDetailsEntities.UserLogins.Add(detali);
                    informationDetailsEntities.SaveChanges();
                    //return RedirectToAction("Login");
                    return(RedirectToAction("Login", "UserLogin"));
                }
            }
            return(View());
        }
Exemplo n.º 3
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            //if (ModelState.IsValid)
            //{

            if (model.NewPassword == model.ConfirmPassword)
            {
                using (InformationDetailsEntities dc = new InformationDetailsEntities())
                {
                    var user = dc.UserLogins.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.password          = Crypto.Hash(model.NewPassword);
                        user.ResetPasswordCode = "";
                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "New password updated successfully";
                    }
                }
            }
            else
            {
                message = "New password and confirm password does not match";
            }
            //}
            //else
            //{
            //    message = "Something invalid";
            //}
            ViewBag.Message = message;
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult ForgotPassword(string EmailID)
        {
            //Verify Email ID
            //Generate Reset password link
            //Send Email
            string message = "";
            bool   status  = false;

            using (InformationDetailsEntities dc = new InformationDetailsEntities())
            {
                var account = dc.UserLogins.Where(a => a.EmailAddress == EmailID).FirstOrDefault();
                if (account != null)
                {
                    //Send email for reset password
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.EmailAddress, resetCode, "ResetPassword");
                    account.ResetPasswordCode = resetCode;
                    //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property
                    //in our model class in part 1
                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset password link has been sent to your email id.";
                }
                else
                {
                    message = "Account not found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }