コード例 #1
0
        public ActionResult RemoveUni(UniModel m)
        {
            if (m.UNI_NAME == null)
            {
                ViewBag.EmptyFields = "Must not leave any University entry fields blank. Try again.";
                return(View("DeleteUni", m));
            }

            grabFromDB DB = new grabFromDB();

            if (DB.getUniversities().Count == 1)
            {
                ViewBag.InvalidUni = "Cannot delete the last university in the database. Try Again.";
                return(View("DeleteUni", m));
            }

            if (DB.getUniversitiesByName(m.UNI_NAME).Count != 1)
            {
                ViewBag.InvalidUni = "This university does not exist in the database. Try Again.";
                return(View("DeleteUni", m));
            }
            else
            {
                DB.removeUniversityByName(m.UNI_NAME);
                ViewBag.ReturnValue = "University successfully removed.";
                return(View("AdminPage"));
            }
        }