public bool AjaxLogin(string email, string password) { using (WowCarryEntities context = new WowCarryEntities()) { bool IsValidUser = context.Customers.Any(user => user.Email.ToLower() == email.ToLower() && user.Password == password); if (IsValidUser) { FormsAuthentication.SetAuthCookie(email, false); return(true); } return(false); } }
public ActionResult Login(LoginViewModel model) { using (WowCarryEntities context = new WowCarryEntities()) { bool IsValidUser = context.Users.Any(user => user.UserName.ToLower() == model.UserName.ToLower() && user.UserPassword == model.Password); if (IsValidUser) { FormsAuthentication.SetAuthCookie(model.UserName, false); return(RedirectToAction("Admin", "Admin")); } ModelState.AddModelError("", "Invalid Username or Password"); return(PartialView()); } }
public string AjaxRegistration(string CustomerName, string Email, string Password) { var addr = new MailAddress(Email); if (addr.Address == Email) { using (WowCarryEntities context = new WowCarryEntities()) { Customers newCustomer = new Customers() { CustomerId = Guid.NewGuid(), Name = CustomerName, Email = Email, Password = Password }; context.Customers.Add(newCustomer); context.SaveChanges(); } FormsAuthentication.SetAuthCookie(Email, false); return("success"); } return("failed"); }