本文整理汇总了C#中Models.IsValid方法的典型用法代码示例。如果您正苦于以下问题:C# Models.IsValid方法的具体用法?C# Models.IsValid怎么用?C# Models.IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Models
的用法示例。
在下文中一共展示了Models.IsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Login
public ActionResult Login(Models.LoginModel userLogin)
{
if (ModelState.IsValid)
{
if (userLogin.IsValid(userLogin.UserName, userLogin.Password,Session.SessionID))
{
//FormsAuthentication.SetAuthCookie(userLogin.UserName, userLogin.RememberMe);
// making the authentication ticket
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1,
userLogin.UserName,
DateTime.Now,
DateTime.Now.AddMinutes(2),
true,
Models.LoginModel.HashString(userLogin.Password));
string encryptedTicket = System.Web.Security.FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName,encryptedTicket);
if (userLogin.RememberMe)
authCookie.Expires = authTicket.Expiration;
Response.Cookies.Add(authCookie);
TempData["user"] = userLogin;
return Redirect(userLogin.returnUrl.ToString());
//return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", "התחברות נכשלה, בדוק את פרטי ההתחברות");
}
}
return View(userLogin);
}
示例2: Login
public JsonResult Login(Models.UserModels.User user)
{
if (ModelState.IsValid)
{
if (user.IsValid(user.UserName2, user.Password2))
{
FormsAuthentication.SetAuthCookie(user.UserName2, user.RememberMe);
return new JsonResult
{
Data = new
{
success = true
}
};
}
else
{
ModelState.AddModelError("", "Login data is incorrect!");
}
}
else
{
var errors = ModelState.Values.SelectMany(v => v.Errors);
}
return new JsonResult
{
Data = new
{
success = false
}
};
}
示例3: Edit
public ActionResult Edit(Models.DisabilityCategoryModel disabilitycategory)
{
if (disabilitycategory.IsValid())
{
Data.CRUD.UpdateDisabilityCategory(disabilitycategory, SessionItems.CurrentUser.UserId);
return Json(new Helpers.JsonAjaxResult.result { notFound = false, noAccess = false, errorList = new[] { "" }, success = true });
}
return Json(new Helpers.JsonAjaxResult.result { notFound = false, noAccess = false, errorList = disabilitycategory.ValidationErrors.ToArray(), success = false });
}
示例4: Create
public ActionResult Create(Models.User user)
{
user.CreateAccount(user.UserName, user.Password, user.Email);
if (user.IsValid(user.UserName, user.Password))
{
FormsAuthentication.SetAuthCookie(user.UserName, true);
return RedirectToAction("Index", "CalendarEvents");
}
return View();
}
示例5: Login
public ActionResult Login(Models.User user)
{
if (user.IsValid(user.UserName, user.Password))
{
FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
return RedirectToAction("MarketsInterna", "Tools");
}
else
{
ModelState.AddModelError("", "Bitte Anmeldedaten prüfen!");
return RedirectToAction("Login", "Account");
}
}
示例6: Create
public ActionResult Create(Models.StudentModel model)
{
model.UserId = Helpers.SessionItems.CurrentUser.UserId;
model.DoValidation();
if (!model.IsValid())
return Json(new Helpers.JsonAjaxResult.result { errorList = model.ValidationErrors.ToArray(), success = false });
else
{
model.UserId = SessionItems.CurrentUser.UserId;
Data.CRUD.InsertStudent(model, SessionItems.CurrentUser.UserId);
return Json(new Helpers.JsonAjaxResult.result { errorList = null, success = true });
}
}
示例7: Login
public ActionResult Login(Models.User user)
{
if (user.IsValid(user.Email, user.Password))
{
Session.Add("CurrentUser", user);
FormsAuthentication.SetAuthCookie(user.Email, true);
return RedirectToAction("Index", "Post");
}
else
{
ModelState.AddModelError("", "Login data is incorrect!");
}
return View(user);
}
示例8: Login
public ActionResult Login(Models.User user)
{
if (ModelState.IsValid)
{
if (user.IsValid(user.Username, user.Password))
{
FormsAuthentication.SetAuthCookie(user.Username, true);
return RedirectToAction("Index", "Home");
}
}
ModelState.AddModelError("", "Login data is incorrect");
return View(user);
}
示例9: Login
public ActionResult Login(Models.User user)
{
if (ModelState.IsValid)
{
if (user.IsValid(user.login, user.password))
{
FormsAuthentication.SetAuthCookie(user.login,(bool)user.remberMe);
return RedirectToAction("Index", "Home", new {id = user.Id });
}
else
{
ModelState.AddModelError("", "Login data is incorrect!");
}
}
return View(user);
}
示例10: Login
public ActionResult Login(Models.User User,string returnUrl)
{
if (ModelState.IsValid)
{
if (User.IsValid(User.UserName))
{
FormsAuthentication.SetAuthCookie(User.UserName, User.RememberMe);
return RedirectToAction("Home", "Home");
}
else
{
ModelState.AddModelError("","Login data is incorrect!");
}
}
return View(User);
}
示例11: Create
public ActionResult Create(Models.DisabilityCategoryModel disabilitycategory)
{
if (Data.Queries.DoesDisabilityCategoryAlreadyExists(disabilitycategory.Description))
{
return Json(new Helpers.JsonAjaxResult.result { notFound = false, noAccess = false, errorList = new[] { disabilitycategory.Description + " already exists" }, success = true });
}
disabilitycategory.ID = 0;
if (disabilitycategory.IsValid())
{
Data.CRUD.InsertDisabilityCategory(disabilitycategory, SessionItems.CurrentUser.UserId);
return Json(new Helpers.JsonAjaxResult.result { notFound = false, noAccess = false, errorList = new[]{""}, success = true });
}
return Json(new Helpers.JsonAjaxResult.result { notFound = false, noAccess = false, errorList = disabilitycategory.ValidationErrors.ToArray(), success = false });
}
示例12: Index
public ActionResult Index(Models.Login.LoginModel user)
{
if (ModelState.IsValid)
{
if (user.IsValid(user.Login, user.Senha))
{
FormsAuthentication.SetAuthCookie(user.Nome, true);
return RedirectToAction("Index", "Carga");
}
else
{
this.ShowMessage(MessageTypeEnum.danger, "Usuário não existe ou não tem autorização para acessar o sistema");
}
}
return View(user);
}
示例13: Login
public ActionResult Login(Models.User user)
{
if (ModelState.IsValid)
{
if (user.IsValid(user.UserName, user.Password))
{
FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
Session["Login"] = user;
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", "Kullanıcı Adınız veya Şifreniz Yanlış!");
}
}
return View(user);
}
示例14: Edit
public ActionResult Edit(Models.StudentIEPModel model)
{
var check = Data.Security.CheckForStudentIEP(model.StudentIEPId.Value, SessionItems.CurrentUser.UserId);
if (!check.Exists)
return Json(new Helpers.JsonAjaxResult.result { notFound = true, noAccess = false, errorList = new string[] { "" }, success = false });
if (!check.HasAccess)
return Json(new Helpers.JsonAjaxResult.result { notFound = false, noAccess = true, errorList = new string[] { "" }, success = false });
model.DoValidation();
if (!model.IsValid())
{
return Json(new Helpers.JsonAjaxResult.result { errorList = model.ValidationErrors.ToArray(), success = false });
}
Data.CRUD.UpdateStudentIep(model, SessionItems.CurrentUser.UserId);
return Json(new Helpers.JsonAjaxResult.result { errorList = new string[] { "" }, success = true });
}
示例15: Index
public ActionResult Index(Models.User user)
{
if (ModelState.IsValid)
{
if (user.IsValid(user.username, user.password))
{
FormsAuthentication.SetAuthCookie(user.username, user.rememberme);
return RedirectToAction("Member", "Home");
}
else
{
ModelState.AddModelError("", "Los datos son incorrectos, verifica tu usuario y password");
}
}
return View(user);
}