public ActionResult Add(User user, int EnqueteID) { if (!db.Enrollments.Where(en => en.UserID == WebSecurity.CurrentUserId && en.role == EnrollmentRole.Owner).Select(en => en.EnqueteID).Contains(EnqueteID)) { return RedirectToAction("Index", "EnqueteBuilder"); } if (!WebSecurity.UserExists(user.Email)) { WebSecurity.CreateUserAndAccount(user.Email, "heelErgGeheimPasswordWatNiemandMagWeten"); user = db.Users.Where(u => u.Email == user.Email).First(); user.GUID = Guid.NewGuid().ToString(); } else { user = db.Users.Where(u => u.Email.Equals(user.Email)).First(); } if (user.BirthDate != null) { if (user.BirthDate.Value.Year < 1900) { user.BirthDate = null; } } var e = new Enrollment(); e.EnqueteID = EnqueteID; e.UserID = user.UserID; e.role = EnrollmentRole.User; db.Enrollments.Add(e); db.SaveChanges(); return RedirectToAction("Index", new { EnqueteID = EnqueteID } ); }
public ActionResult Index(User u) { if (ModelState.IsValid) { db.Entry(u).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("Index"); }