Beispiel #1
0
        public ActionResult Reset_Password()
        {
            try
            {
                int ID      = Convert.ToInt32(Session["Trainer_ID"]);
                var trainer = db.Trainers.Where(i => i.ID == ID).FirstOrDefault();
                Reset_PasswordModel Reset_PasswordModel = new Reset_PasswordModel();
                Reset_PasswordModel.Role_ID = Convert.ToInt32(trainer.Role_ID);
                return(View(Reset_PasswordModel));
            }

            catch (Exception ex)
            {
                return(RedirectToAction("Contact", "Home"));
            }
        }
Beispiel #2
0
        public ActionResult Reset_Password(Reset_PasswordModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int ID      = Convert.ToInt32(Session["Trainer_ID"]);
                    var trainer = db.Trainers.Where(i => i.ID == ID).FirstOrDefault();
                    trainer.Password = model.Password;
                    db.SaveChanges();
                    TempData["Success"] = "Password has been reset successfully!! ";
                    if (trainer.Role_ID == 1)
                    {
                        return(RedirectToAction("Owner", "Dashbord"));
                    }
                    if (trainer.Role_ID == 2)
                    {
                        return(RedirectToAction("Manager", "Dashbord"));
                    }
                    return(View());
                }
                else
                {
                    TempData["Error"] = "Please Fill All Required Details.!";
                    int ID      = Convert.ToInt32(Session["Trainer_ID"]);
                    var trainer = db.Trainers.Where(i => i.ID == ID).FirstOrDefault();
                    Reset_PasswordModel Reset_PasswordModel = new Reset_PasswordModel();
                    Reset_PasswordModel.Role_ID = Convert.ToInt32(trainer.Role_ID);
                    return(View(Reset_PasswordModel));
                }
            }

            catch (Exception ex)
            {
                return(RedirectToAction("Contact", "Home"));
            }
        }