public async Task <ActionResult> Register(RegisterViewModel model, string returnUrl)
        {
            //do not use userManager to create users use the house service, it will create profile for you
            if (ModelState.IsValid)
            {
                var user   = Mapper.Map <OldHouseUser>(model);
                var result = await MyService.CreateUserWithProfile(user, new HashSet <string> {
                    OldHouseUserProfile.PROFILENBAME
                });

                if (result.IsSuccessful)
                {
                    var loginClaim = await MyService.MyUserManager.Login(model.UserName, model.Password, DateTime.Now.AddDays(7));

                    if (loginClaim != null)
                    {
                        Jtext103AuthMiddleware <OldHouseUser> .Login(HttpContext.GetOwinContext().Environment, loginClaim);
                    }
                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    AddErrors(result);
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                //add 7 days to the security stamp
                var loginClaim = await MyService.MyUserManager.Login(model.UserName, model.Password, DateTime.Now.AddDays(7));

                if (loginClaim != null)
                {
                    loginClaim.Remember = model.RememberMe;
                    Jtext103AuthMiddleware <OldHouseUser> .Login(HttpContext.GetOwinContext().Environment, loginClaim);

                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    ModelState.AddModelError("", "Invalid username or password.");
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }
        public ActionResult Logout()
        {
            Jtext103AuthMiddleware <OldHouseUser> .Logout(HttpContext.GetOwinContext().Environment);

            return(RedirectToAction("Index", "Home", new { area = "" }));
        }