/// <summary> /// Saves selected data into the College Database /// If the college already exists it throws a pop up error to the user. /// </summary> public ActionResult SaveData() { int userID = Int32.Parse(Request.QueryString["UserID"]); string name = Request.QueryString["Name"]; string stateName = Request.QueryString["StateName"]; string city = Request.QueryString["City"]; int zipCode = Int32.Parse(Request.QueryString["ZipCode"]); string accreditor = Request.QueryString["Accreditor"]; string degree = Request.QueryString["Degree"]; string degreeType = Request.QueryString["DegreeType"]; int ownership = Int32.Parse(Request.QueryString["Ownership"]); int cost; int.TryParse(Request.QueryString["Cost"], out cost); if (_repository.GetCollege(name, userID) == 0) { SearchResult college = new SearchResult { CompanionID = userID, Name = name, StateName = stateName, City = city, ZipCode = zipCode, Accreditor = accreditor, Degree = degree, DegreeType = degreeType, Ownership = ownership, Cost = cost }; if (User.Identity.IsAuthenticated) { Debug.WriteLine("saveData() Method!"); if (ModelState.IsValid) { _repository.AddCollege(college); _repository.SaveCollege(college); System.Windows.Forms.MessageBox.Show("You Have Successfully Saved This College"); return(RedirectToAction("SaveDataList", "Home")); } else { Debug.WriteLine("Error for SaveData() method."); return(View()); } } else { return(RedirectToAction("Login", "Account")); } } else { System.Windows.Forms.MessageBox.Show("You Have Already Saved This College"); return(RedirectToAction("SaveDataList", "Home")); } }
public void AddCollege(College college) { collegeRepository.AddCollege(college); }