public JsonResult _Login(LoginModel loginModel) { /// /// NOTE: This is where your logic goes /// //for testing if (ModelState.IsValid) { if (loginModel.IsValidUser(loginModel.Login, loginModel.Password)) { Session["user"] = new LoginModel() {Login = loginModel.Login}; return Json(JsonResponseFactory.SuccessResponse(), JsonRequestBehavior.DenyGet); } else { ModelState.AddModelError("", "Błędne dane logowania."); return Json(JsonResponseFactory.ErrorResponse("Błędne dane logowania."), JsonRequestBehavior.DenyGet); } } else { return Json(JsonResponseFactory.ErrorResponse(""), JsonRequestBehavior.DenyGet); } }
public JsonResult _Login(LoginModel model) { /// /// NOTE: This is where your logic goes /// //for testing if (model.UserName == "fail") { return Json(JsonResponseFactory.ErrorResponse("You told me to fail."), JsonRequestBehavior.DenyGet); } else { return Json(JsonResponseFactory.SuccessResponse(), JsonRequestBehavior.DenyGet); } }