public ActionResult Create(User user) { System.Diagnostics.Debug.WriteLine("POST create"); if (ModelState.IsValid) { context.Users.Add(user); context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
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 CreateTeacher(User user, string teacherTitle, int clUniversityId) { if (ModelState.IsValid) { context.Users.Add(user); CmTeacher newTeacher = new CmTeacher(); newTeacher.userID = user.ID;//TODO - probably newTeacher.clUniversityId = clUniversityId; if(teacherTitle.Equals("no")){ newTeacher.title = ""; } else { newTeacher.title = teacherTitle; } context.CmTeachers.Add(newTeacher); context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult UserCustomView(User userModel, String user, string pass) { System.Diagnostics.Debug.WriteLine("are we in the game?"); var userTry = context.Users.Where(s => s.Email.Contains(user)); //IQueryable<User> result = userTry.SingleOrDefault; // if (result != null) // { // //results = String.Format("Welcome, {0}!", userTry); // //return RedirectToAction("Details", new { id = userTry.ID }); // return RedirectToAction("Create"); // } // else // { // return RedirectToAction("Index" ); // } return View(userTry); }
public ActionResult Edit(User user) { if (ModelState.IsValid) { context.Entry(user).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }