示例#1
0
        public async Task <ActionResult> AddUsers(UserToAddModel user)
        {
            var vaultUser = new VaultUser()
            {
                Id       = user.UserId,
                UserName = (await UserManager.FindByIdAsync(user.UserId)).UserName
            };

            if (user.AccessRight == "Read")
            {
                await _accessManager.GrantReadAccess(vaultUser, user.VaultId);
            }
            if (user.AccessRight == "Create")
            {
                await _accessManager.GrantCreateAccess(vaultUser, user.VaultId);
            }
            await _accessManager.ValidateUserAccessRights(user.VaultId, user.UserId);

            return(RedirectToAction("EditUsers", new { id = user.VaultId }));
        }