Esempio n. 1
0
        public ActionResult RemoveAdmin(AdminModel m)
        {
            if (m.UserEmail == null)
            {
                ViewBag.EmptyFielsAdnminEntry = "Must not leave any Admin entry fields blank. Try again.";
                return(View("DeleteAdmin", m));
            }

            if (m.UserEmail == AbstractDatabase.AdminEmail)
            {
                ViewBag.InvalidEmail = "Cannot remove that admin. Try again.";
                return(View("DeleteAdmin", m));
            }

            if (m.UserEmail.Length > 100)
            {
                ViewBag.InvalidEmail = "Email too long. Try again.";
                return(View("DeleteAdmin", m));
            }

            grabFromDB DB = new grabFromDB();

            //check if valid user
            if (DB.getAdminByEmail(m.UserEmail).Count == 0)
            {
                ViewBag.InvalidEmail = "This email is not associated with a current admin. Try again.";
                return(View("DeleteAdmin", m));
            }
            else
            {
                DB.removeAdminByEmail(m.UserEmail);
                ViewBag.ReturnValue = "Admin successfully removed.";
                return(View("AdminPage"));
            }
        }