public Member Add(NewMemberModel newMember) { Member member = new Member { Username = newMember.Username, FirstName = newMember.FirstName, LastName = newMember.LastName, Email = newMember.Email, LastActivity = DateTime.Now, Password = Crypto.HashPassword(newMember.Password) }; db.Members.Add(member); db.SaveChanges(); return member; }
public ActionResult Register(NewMemberModel newMember) { try { if (ModelState.IsValid) { MemberManager memberManager = new MemberManager(); if (!memberManager.UsernameExist(newMember.Username)) { var registeredMember = memberManager.Add(newMember); FormsAuthentication.SetAuthCookie(registeredMember.Username, false); return RedirectToAction("Welcome", "Home"); } else { ModelState.AddModelError("", "Username already taken."); } } } catch (Exception e) { ModelState.AddModelError("", e.ToString()); } return View(newMember); }