public ActionResult Create(UserProfile userprofile) { if (ModelState.IsValid) { db.UserProfiles.Add(userprofile); db.SaveChanges(); return RedirectToAction("Index"); } return View(userprofile); }
public ActionResult Create(UserProfile userprofile) { if (ModelState.IsValid) { db.UserProfiles.Add(userprofile); db.SaveChanges(); Roles.AddUserToRole(userprofile.UserName, Helpers.TEACHER_ROLE); db.SaveChanges(); return RedirectToAction("Index"); } return View(userprofile); }
public ActionResult AddPhoto(int id = 0) { StudentPhotoViewModel vm = new StudentPhotoViewModel(); var user = new UserProfile(); if (id != 0) { user = db.UserProfiles.Find(id); } if (user == null) { return HttpNotFound(); } vm.FullName = user.FullName; vm.UserId = user.UserId; return View(vm); }
public ActionResult Create(UserProfile userprofile) { if (ModelState.IsValid) { userprofile.CreationDate = DateTime.Now; userprofile.FutureStudent = true; //Todo: currently requires two trips to db to autogenerate username. db.UserProfiles.Add(userprofile); db.SaveChanges(); userprofile.UserName = "******" + userprofile.UserId; db.Entry(userprofile).State = EntityState.Modified; db.SaveChanges(); Roles.AddUserToRole(userprofile.UserName, Helpers.STUDENT_ROLE); return RedirectToAction("Index"); } return View(userprofile); }
public ActionResult Edit(UserProfile userprofile) { if (ModelState.IsValid) { db.Entry(userprofile).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(userprofile); }