public ActionResult SaveStuClub(Student_Club studentClub, string language) { ChangeLanguageFunction(language); if (!ModelState.IsValid) { var clubs = _context.Clubs.ToList(); var viewModels = new StudentClubViewModel() { StudentClub = new Student_Club(Session["Id"].ToString()), Clubs = clubs }; } _context.StudentClubs.Add(studentClub); try { _context.SaveChanges(); } catch (DbUpdateException) { MessageBox.Show(StudentActivity.Resources.Language.Already_a_member_of_the_club, "Existence Error"); } return(RedirectToAction("ShowClubs", "EnglishClub")); }
public ActionResult SaveStuClub(Student_Club studentClub, string language) { ChangingLanguageFunction(language); if (!ModelState.IsValid) { var clubs = _context.Clubs.ToList(); var viewModels = new StudentClubViewModel() { StudentClub = new Student_Club(Session["Id"].ToString()), Clubs = clubs }; } _context.StudentClubs.Add(studentClub); try { _context.SaveChanges(); // Sends StudentClubAddedMessage to the another action using the TempData TempData["StudentClubAddedMessage"] = 1; } catch (DbUpdateException) { //MessageBox.Show(StudentActivity.Resources.Language.Already_a_member_of_the_club, "Existence Error"); // Sends StudentClubRegisteredErrorMessage to the another action using the TempData TempData["StudentClubRegisteredErrorMessage"] = 1; return(RedirectToAction("ShowClubs", "Club")); } return(RedirectToAction("ShowClubs", "Club")); }