public ActionResult CreateManager(AdminManager a) { if (!user.IsAdmin()) { return(View("Error")); } a.RoleID = 2; a.LastLogin = DateTime.Now; string encryptedPass = Common.Encryptor.MD5Hash(a.Password); a.Password = encryptedPass; if (ModelState.IsValid) { if (managerDal.CheckUserName(a.Username)) { ViewBag.error = "The Username already exists!!!"; } else if (managerDal.CheckEmail(a.Email)) { ViewBag.error = "The email already exists!!!"; } else if (managerDal.CheckPhone(a.Phone)) { ViewBag.error = "The phone number already exists!!!"; } else { bool check = managerDal.CreateADManager(a); if (!check) { TempData["UserName"] = false; TempData["statusCC"] = "Manager age must be 18 or older"; } else { TempData["stt"] = true; TempData["stt"] = "More success---"; } return(RedirectToAction("ManagerList", "Admin")); } } return(View(a)); }