コード例 #1
0
        private void CreateSiteUser(ApplicationUser user)
        {
            var libUser = new LibraryUserViewModel
            {
                UserName = user.Email,
                UserRole = "Customer",
                Status   = Enums.UserStatus.Active
            };

            var libUserCmd = new LibraryUserCommand();

            libUserCmd.Execute(libUser);
        }
コード例 #2
0
        public async Task <ActionResult> RemoveLockOutConfirmed(int id)
        {
            if (ModelState.IsValid)
            {
                if (id > 0)
                {
                    var user = await UserManager.FindByIdAsync(id);

                    if (user == null)
                    {
                        return(HttpNotFound());
                    }

                    user.LockoutEndDateUtc = DateTime.Now.AddDays(-1);

                    var result = await UserManager.UpdateAsync(user);

                    if (!result.Succeeded)
                    {
                        ModelState.AddModelError("", result.Errors.First());
                        return(View());
                    }

                    var userModel = new LibraryUserViewModel
                    {
                        UserName = user.UserName,
                        Status   = Enums.UserStatus.Active
                    };

                    var userCommand = new LibraryUserCommand();
                    userCommand.Execute(userModel);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
            }
            return(View());
        }