public ActionResult Create(CmStudent cmstudent) { if (ModelState.IsValid) { context.CmStudents.Add(cmstudent); context.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Possibleusers = context.Users; ViewBag.PossibleclUniversities = context.ClUniversities; return View(cmstudent); }
public ActionResult CreateStudent(User user, string course, byte courseYear, int clUniversityId) { if (ModelState.IsValid) { context.Users.Add(user); CmStudent newStudent = new CmStudent(); newStudent.userID = user.ID; newStudent.clUniversityId = clUniversityId; if(courseYear.Equals(6)){ newStudent.courseYear = 6; } else { newStudent.courseYear = courseYear; } context.CmStudents.Add(newStudent); context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult Edit(CmStudent cmstudent) { if (ModelState.IsValid) { context.Entry(cmstudent).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Possibleusers = context.Users; ViewBag.PossibleclUniversities = context.ClUniversities; return View(cmstudent); }