public ActionResult Register(string fname, string lname, string email, string school, string password, string role) { if (role.ToLower().Equals("teacher")) { Teacher newTeacher = new Teacher { FirstName = fname, LastName = lname, Email = email, School = school, Password = password }; Context.Teachers.Add(newTeacher); Context.SaveChanges(); } else { Student newStudent = new Student { FirstName = fname, LastName = lname, Email = email, School = school, Password = password }; Context.Students.Add(newStudent); Context.SaveChanges(); } return(View("Index")); }
public ActionResult AddClass(string name) { _Class newClass = new _Class { Name = name }; Context._Classes.Add(newClass); Context.SaveChanges(); Teacher teacher = Context.Teachers.Single(t => t.Email == Email); ManageClassesViewModel mcvm = new ManageClassesViewModel { FirstName = teacher.FirstName, LastName = teacher.LastName, _Classes = Context._Classes.ToList() }; return(View("ManageClasses_Teacher", mcvm)); }