예제 #1
0
        public JsonResult AjaxLogin(string EmailAddress, string Password)
        {
            try
            {
                Models.CUser User = new Models.CUser();

                User = User.Login(EmailAddress, Password);

                if (User.ActionStatus == Models.CUser.ActionStatusTypes.UserLoggedIn)
                {
                    User.SetCurrentUser();
                    return(Json(new { FirstName = User.FirstName
                                      , LastName = User.LastName
                                      , UserID = User.UserID
                                      , ActionStatus = User.ActionStatus }));
                }
                else
                {
                    return(Json(new { FirstName = ""
                                      , LastName = ""
                                      , UserID = 0
                                      , ActionStatus = Models.CUser.ActionStatusTypes.FailedLogin }));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #2
0
        public ActionResult Login(FormCollection Collection)
        {
            try
            {
                Models.CDatabase db   = new Models.CDatabase();
                Models.CUser     User = new Models.CUser();
                User.EmailAddress = Collection["EmailAddress"];
                User.Password     = Collection["Password"];

                User = User.Login(User.EmailAddress, User.Password);

                if (User.UserID > 0)
                {
                    User.SetCurrentUser();
                    return(RedirectToAction("Home", "Home"));
                }
                else
                {
                    return(View(User));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }