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


C# Models.UpdateLastLoginDate方法代码示例

本文整理汇总了C#中Models.UpdateLastLoginDate方法的典型用法代码示例。如果您正苦于以下问题:C# Models.UpdateLastLoginDate方法的具体用法?C# Models.UpdateLastLoginDate怎么用?C# Models.UpdateLastLoginDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Models的用法示例。


在下文中一共展示了Models.UpdateLastLoginDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Login

        public ActionResult Login( Models.User user )
        {
            if( ModelState.IsValid ) {
                //Check if password is valid
                if( user.IsPasswordValid( user.Username, user.Password ) ) {
                    //Password is valid, create authentication cookie
                    FormsAuthentication.SetAuthCookie( user.Username, false );

                    //Update LastLoginDate in the database for future usage statistics
                    user.UpdateLastLoginDate( user.Username );

                    //Refresh site
                    return RedirectToAction( "Index", "Index" );
                }
                else {
                    //Username or password is not valid, display an error
                    //For additional security do not specify if username exists
                    ModelState.AddModelError( "", "Username or password is incorrect" );
                }
            }

            return View( user );
        }
开发者ID:slaxton,项目名称:InterviewAssignment,代码行数:23,代码来源:UserController.cs

示例2: Create

        public ActionResult Create( Models.User user )
        {
            if( ModelState.IsValid ) {
                //Check if username already exists in the database
                if( user.IsUsernameInUse( user.Username ) ) {
                    ModelState.AddModelError( "", "Username already exists, please try a different one" );
                }
                else {
                    //Username does not exist, create new user
                    user.CreateNewUser( user.Username, user.Password );

                    //Create authentication cookie for new account
                    FormsAuthentication.SetAuthCookie( user.Username, false );

                    //Update LastLoginDate in the database for future usage statistics
                    user.UpdateLastLoginDate( user.Username );

                    //Refresh site
                    return RedirectToAction( "Index", "Index" );
                }
            }

            return View( user );
        }
开发者ID:slaxton,项目名称:InterviewAssignment,代码行数:24,代码来源:UserController.cs


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