コード例 #1
0
    public ActionResult Delete(string email, string roleName)
    {
        UserRoleRepo userRoleRepo = new UserRoleRepo(_serviceProvider);

        userRoleRepo.RemoveUserRole(email, roleName);
        return(RedirectToAction("Detail", "UserRole",
                                new { userName = email }));
    }
コード例 #2
0
        public void MakeUserManager([FromBody] EmployeeIdVM employee)
        {
            //This method simply strips the Employee role from the user and then adds on the Manager role
            UserRoleRepo repo = new UserRoleRepo(service);

            repo.RemoveUserRole(employee.Email, "Employee").Wait();
            repo.AddUserRole(employee.Email, "Manager").Wait();
        }
コード例 #3
0
        public async Task <IActionResult> DeleteUserRole(string email, string roleName)
        {
            if (ModelState.IsValid)
            {
                UserRoleRepo userRoleRepo = new UserRoleRepo(_serviceProvider);
                var          success      = await userRoleRepo.RemoveUserRole(email, roleName);

                if (success)
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }
            ViewBag.Error = "An error occurred while deleting this role. Please try again.";
            return(View());
        }
コード例 #4
0
        public async Task <ActionResult> Remove(UserRoleVM userRoleVM)
        {
            UserRoleRepo userRoleRepo = new UserRoleRepo(_serviceProvider);

            if (ModelState.IsValid)
            {
                var addUR = await userRoleRepo.RemoveUserRole(userRoleVM.Email,
                                                              userRoleVM.Role);
            }
            try
            {
                return(RedirectToAction("Detail", "UserRole",
                                        new { userName = userRoleVM.Email }));
            }
            catch
            {
                return(View());
            }
        }