Exemplo n.º 1
0
        public ActionResult ChangePassword(ChangePassword cp, AdminLogin al, Registration r)
        {
            if (ModelState.IsValid)
            {
                string username = Session["UserName"].ToString();
                al = db.AdminLogins.Where(a => a.UserName == username && a.Password == cp.OldPassword).FirstOrDefault();
                if (al != null)
                {
                    al.Password        = cp.Password;
                    al.ConfirmPassword = cp.ConfirmPassword;
                    db.SaveChanges();
                    return(RedirectToAction("Login", "Leads"));
                }

                else
                {
                    r = db.Registrations.Where(a => a.UserName == username && a.Password == cp.Password).FirstOrDefault();
                    if (r != null)
                    {
                        r.Password        = cp.Password;
                        r.ConfirmPassword = cp.ConfirmPassword;
                        db.SaveChanges();
                        return(RedirectToAction("Login", "Leads"));
                    }
                    else
                    {
                        ViewBag.Message = "Sorry! Invalid Old Password!";
                    }
                }
            }
            return(View());
        }
Exemplo n.º 2
0
        public JsonResult SaveDataInDataBase(EmployeeViewModel model)
        {
            var result = false;

            try
            {
                if (model.EmpId > 0)
                {
                    Registration reg = db.Registrations.SingleOrDefault(x => x.IsDeleted == false && x.EmpId == model.EmpId);
                    reg.FirstName    = model.FirstName;
                    reg.LastName     = model.LastName;
                    reg.UserName     = model.UserName;
                    reg.Email        = model.Email;
                    reg.MobileNumber = model.MobileNumber;
                    reg.Roles_Id     = model.Roles_Id;
                    reg.TeamId       = model.TeamId;
                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    Registration reg = new Registration();
                    reg.FirstName       = model.FirstName;
                    reg.LastName        = model.LastName;
                    reg.UserName        = model.UserName;
                    reg.Email           = model.Email;
                    reg.MobileNumber    = model.MobileNumber;
                    reg.Password        = model.Password;
                    reg.ConfirmPassword = model.ConfirmPassword;
                    reg.Roles_Id        = model.Roles_Id;
                    reg.TeamId          = model.TeamId;
                    db.Registrations.Add(reg);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }