Esempio n. 1
0
 public ActionResult EditManager(AdminManager a)
 {
     if (!user.IsAdmin())
     {
         return(View("Error"));
     }
     if (managerDal.CheckPass_Update(a) == false)
     {
         string encryptedPass = Common.Encryptor.MD5Hash(a.Password);
         a.Password = encryptedPass;
     }
     if (managerDal.CheckUserName_Update(a))
     {
         ViewBag.error = "The Username already exists!!!";
     }
     else if (managerDal.CheckEmail_Update(a))
     {
         ViewBag.error = "The email already exists!!!";
     }
     else if (managerDal.CheckPhone_Update(a))
     {
         ViewBag.error = "The phone number already exists!!!";
     }
     else
     {
         bool check = managerDal.UpdateADManager(a);
         if (!check)
         {
             TempData["UserName"] = false;
             TempData["statusCC"] = "Manager age must be 18 or older";
         }
         else
         {
             TempData["stt"] = true;
             TempData["stt"] = "Correction successful";
             return(RedirectToAction("ManagerList", "Admin"));
         }
         return(View(a));
     }
     return(View(a));
 }