Ejemplo n.º 1
0
        public ActionResult SignIn()
        {
            var person= new PersonModel();
            //todo

            return View("SignIn", person);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        public Object CreateUserResponse(PersonModel person)
        {
            var status = projector.CreatePerson(person);

            var data = new { status };

            return data;
        }
Ejemplo n.º 5
0
        public Object AuthenticateUserResponse(PersonModel person)
        {
            var status = projector.AuthenticateUser(person);

            var data = new { status };

            return data;
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
 public ActionResult ValidateUsers(PersonModel person)
 {
     var personSvc = new PersonService();
     Object data = personSvc.AuthenticateUserResponse(person);
     return Json(data, JsonRequestBehavior.AllowGet);
 }