コード例 #1
0
        public IActionResult AddUserGroup([FromBody] AssignUserToGroupView model)
        {
            if (model != null)
            {
                var roles = _application.SetUserGroups(model.UserId, model.groupname);
                return(Ok(roles));
            }

            return(BadRequest());
        }
コード例 #2
0
        public IActionResult Add(InternalUserViewModel models)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    Email    = models.Email,
                    UserName = models.Email,
                };

                var result = _userManager.CreateAsync(user: user, password: models.Password).Result;
                if (result.Succeeded)
                {
                    var resultFromAssigningPermission = _groupManager.SetUserGroups(user.Id, models.Roles);
                    if (resultFromAssigningPermission.Succeeded)
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }

            return(View(models));
        }