Beispiel #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"));
            }
        }
Beispiel #2
0
        private IEnumerable <string> GetAllUniversities()
        {
            //This could be a call to University in Database
            grabFromDB     grabFromDB = new grabFromDB();
            List <UniData> uni        = grabFromDB.getUniversities();
            List <string>  output     = new List <string>();
            string         temp;

            grabFromDB.close();
            foreach (UniData data in uni)
            {
                temp = data.name;
                output.Add(temp);
            }
            return(output);
        }