public ActionResult SignIn() { var person= new PersonModel(); //todo return View("SignIn", person); }
public string CreatePerson(PersonModel person) { var response = string.Empty; if (String.IsNullOrEmpty(person.FirstName) || String.IsNullOrEmpty(person.LastName) || String.IsNullOrEmpty(person.UserName) || String.IsNullOrEmpty(person.Password)) return response = "All fields are required..."; try { var createNew = entityProjects.People.Add(new Person { FirstName = person.FirstName, LastName = person.LastName, UserName = person.UserName, Password = person.Password }); entityProjects.SaveChanges(); response = "User Successfully Added"; } catch (Exception ex) { _logger.Fatal(string.Format("{0} | {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, ex)); response = "Exception Error"; } return response; }
public string AuthenticateUser(PersonModel person) { var authenticationStatus = string.Empty; if (String.IsNullOrEmpty(person.UserName) || String.IsNullOrEmpty(person.Password)) return authenticationStatus = "User name and password is required!"; else { try { var isAuthenticated = entityProjects.People.Where(a => a.UserName == person.UserName && a.Password == a.Password); if (isAuthenticated.Any()) { authenticationStatus = "User found..."; } else authenticationStatus="Invalid user name or password!"; } catch (Exception ex) { _logger.Fatal(string.Format("{0} | {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, ex)); authenticationStatus = "Exception Error"; } } return authenticationStatus; }
public Object CreateUserResponse(PersonModel person) { var status = projector.CreatePerson(person); var data = new { status }; return data; }
public Object AuthenticateUserResponse(PersonModel person) { var status = projector.AuthenticateUser(person); var data = new { status }; return data; }
public Object AuthenticateUserResponse(PersonModel person) { var status = projector.AuthenticateUser(person); if (status == "User found...") { FormsAuthentication.SetAuthCookie(person.UserName, false); } var data = new { status }; return data; }
public ActionResult ValidateUsers(PersonModel person) { var personSvc = new PersonService(); Object data = personSvc.AuthenticateUserResponse(person); return Json(data, JsonRequestBehavior.AllowGet); }