当前位置: 首页>>代码示例>>C#>>正文


C# Models.IsValid方法代码示例

本文整理汇总了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);
        }
开发者ID:nir-z,项目名称:HaifanetMobile,代码行数:34,代码来源:LoginController.cs

示例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
         }
     };
 }
开发者ID:TOByrne,项目名称:TGOByrne,代码行数:32,代码来源:UserController.cs

示例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 });
 }
开发者ID:thilehoffer,项目名称:CSM,代码行数:9,代码来源:DisabilityCategoryController.cs

示例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();
 }
开发者ID:reserad,项目名称:Local-Web-Server,代码行数:10,代码来源:AccountController.cs

示例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");
     }
 }
开发者ID:Lilochen,项目名称:DeGalgnveglWebsite,代码行数:13,代码来源:AccountController.cs

示例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 });
     }
     
 }
开发者ID:thilehoffer,项目名称:CSM,代码行数:14,代码来源:StudentController.cs

示例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);
 }
开发者ID:EMA-INFRES4,项目名称:ema-stackoverflow,代码行数:14,代码来源:AccountController.cs

示例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);
        }
开发者ID:ericsmallwood,项目名称:Greenlight,代码行数:15,代码来源:UserController.cs

示例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);
 }
开发者ID:XonyON,项目名称:Work,代码行数:16,代码来源:UserController.cs

示例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);
 }
开发者ID:Quotes,项目名称:Web_App,代码行数:16,代码来源:HomeController.cs

示例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 });
        }
开发者ID:thilehoffer,项目名称:CSM,代码行数:16,代码来源:DisabilityCategoryController.cs

示例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);
        }
开发者ID:Workker,项目名称:Orcamento2015,代码行数:17,代码来源:LoginController.cs

示例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);
 }
开发者ID:gacaromar,项目名称:LoL,代码行数:17,代码来源:LoginController.cs

示例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 });
        }
开发者ID:thilehoffer,项目名称:CSM,代码行数:18,代码来源:StudentIEPController.cs

示例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);
        }
开发者ID:payucon5103,项目名称:DevHaven,代码行数:19,代码来源:HomeController.cs


注:本文中的Models.IsValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。