public ActionResult Edit(User user) { if (ModelState.IsValid) { context.Entry(user).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult Create(User user) { //TODO: check email deosnt exist already if (ModelState.IsValid) { context.Users.Add(user); context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public void Can_specify_user_as_owner() { var sut = new Card(); var user = new User(); var userLink = new UserLink { User = user, LinkType = UserLinkType.Owner }; sut.UserLinks.Add(userLink); Assert.AreEqual(1, sut.UserLinks.Count); }
public void Can_add_a_user_to_a_card() { var sut = new Card(); var user = new User(); var userLink = new UserLink { User = user }; sut.UserLinks.Add(userLink); Assert.AreEqual(1, sut.UserLinks.Count); }
public void Can_add_a_user() { var sut = new User(); Assert.IsNotNull(sut); }
public ActionResult Signup(SignupViewModel model) { if (ModelState.IsValid) { var user = new User { Name = model.Name, Email = model.Email, Password = model.Password, //TODO: Hash this Created = DateTime.Now, Modified = DateTime.Now }; context.Users.Add(user); context.SaveChanges(); var newUser = context.Users.SingleOrDefault(x => x.Email == user.Email && x.Password == model.Password); if (newUser != null) FormsAuthentication.SetAuthCookie(newUser.Id.ToString(), user.RememberMe); return RedirectToAction("Index", "Dashboard"); } return View(model); }
public ActionResult Login(User model) { if (ModelState.IsValid) { var user = context.Users.SingleOrDefault(x => x.Email == model.Email && x.Password == model.Password); if (user != null) { FormsAuthentication.SetAuthCookie(user.Id.ToString(), user.RememberMe); return RedirectToAction("Index", "Dashboard"); } else { ModelState.AddModelError("", "Login data is incorrect!"); } } return View(model); }