public ActionResult Login(Member member) { if (ModelState.IsValid) { using (BlogContext db = new BlogContext(ConfigurationManager.ConnectionStrings["BlogContext"].ConnectionString)) { string hashPass=EncryptString(member.Password,_passPhrase); var v = db.Members.FirstOrDefault(a => a.UserName.Equals(member.UserName) && a.Password.Equals(hashPass)); if (v == null) return View(member); Session["LoggedUserID"] = v.UserId.ToString(); Session["LoggedUserName"] = String.IsNullOrEmpty(v.NickName) ? v.UserName : v.NickName; return RedirectToAction("Index", "Dashboard"); } } return View(member); }
public ActionResult Signup( Member member) { if (ModelState.IsValid) { using (BlogContext db = new BlogContext(ConfigurationManager.ConnectionStrings["BlogContext"].ConnectionString)) { member.UserId = null; member.IsActive = 1; member.Password=EncryptString(member.Password, _passPhrase); db.Members.Add(member); db.SaveChanges(); } return Content("Congratulation ! New Member "+(String.IsNullOrEmpty(member.NickName) ? member.UserName : member.NickName)+". Please <b><a href='/Admin/Login'>Click Here to Login</a></b>"); } else return View(); }