public JsonResult JsonLogin(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (userService.CheckLoginSuccess(model.UserName, model.Password))
                {
                    Session["user"] = userService.LoadByUserName(model.UserName);
                    return Json(new { success = true, redirect = "/Home" });
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed
            return Json(new { errors = GetErrorsFromModelState() });
        }
 public ActionResult Login(LoginModel myLoginModel)
 {
     if (userService.CheckLoginSuccess(myLoginModel.UserName, myLoginModel.Password))
     {
         Session["user"] = userService.LoadByUserName(myLoginModel.UserName);
         return RedirectToAction("Index", "UserGroup");
     }
     else
     {
         ViewBag.ErrorMessage = "Login Failed!";
         return View("Index");
     }
 }