/// <summary> /// Return permisionoverview with edit info /// </summary> /// <param name="selectedPermission">Identification of permission</param> /// <returns>Returns actionresult permissionoverview</returns> public IActionResult OverviewEdit(int selectedPermission) { var model = new RolePermissionViewModel(); RoleController rc = new RoleController(); var selected = permissionRep.RetrievePermissionById(selectedPermission); var allRoles = roleRep.RetrieveAllRoles(); var allPermissions = permissionRep.RetrieveAllPermissions(); if (selected != null) { model.Name = selected.RetrievePermissionName(); model.Id = selected.RetrievePermissionId(); model.Description = selected.RetrievePermissionDescription(); model.AllPermissionsInSystem = AutoMappingRolePermissionViewModel().AllPermissionsInSystem; model.AllRolesInSystem = AutoMappingRolePermissionViewModel().AllRolesInSystem; foreach (Role r in rc.RetrieveRolesFromPermission(selected)) { var mapperThree = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapperThree.Map <RoleOverviewViewModel>(r); model.AllRolesWithPermission.Add(rmodel); } return(View("Permissionoverview", model)); } return(View("Permissionoverview", model)); }
/// <summary> /// Return useroverview /// </summary> /// <returns>Actionresult useroverview</returns> public IActionResult Overview() { var model = new UserRoleViewModel(); var rc = new RoleController(); model.AllUserRoles = new List <RoleOverviewViewModel>(); foreach (Role r in roleRep.RetrieveAllRoles()) { var mapperOne = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapperOne.Map <RoleOverviewViewModel>(r); model.AllUserRoles.Add(rmodel); } foreach (User u in userRep.RetrieveAllUsers()) { var mapperTwo = mapextension.UserToUserOverviewViewModel(); UserOverviewViewModel umodel = mapperTwo.Map <UserOverviewViewModel>(u); foreach (Role r in roleRep.RetrieveRolesFromUser(u)) { RoleOverviewViewModel rmodel = new RoleOverviewViewModel(); rmodel.RoleId = r.RetrieveRoleId(); rmodel.RoleName = r.RetrieveRoleName(); umodel.RolesInUser.Add(rmodel); } model.UsersInSystem.Add(umodel); } return(View("Useroverview", model)); }
/// <summary> /// Return roleoverview /// </summary> /// <returns>Return roleoverview</returns> public IActionResult Overview() { var model = new RoleViewModel(); model.AllRolesInSystem = new List <RoleOverviewViewModel>(); foreach (Role r in roleRep.RetrieveAllRoles()) { var mapper = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapper.Map <RoleOverviewViewModel>(r); model.AllRolesInSystem.Add(rmodel); } return(View("RoleOverview", model)); }
/// <summary> /// Return singleuser page /// </summary> /// <returns>Actionresult singleuser</returns> public IActionResult Single() { var model = new UserRoleViewModel(); model.AllUserRoles = new List <RoleOverviewViewModel>(); foreach (Role r in roleRep.RetrieveAllRoles()) { var mapper = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapper.Map <RoleOverviewViewModel>(r); model.AllUserRoles.Add(rmodel); } return(View("SingleUser", model)); }
/// <summary> /// Return roleoverview with info /// </summary> /// <param name="selectedRole">Id of the role to edit</param> /// <returns>Return roleoverview</returns> public IActionResult OverviewEdit(int selectedRole) { var allRoles = roleRep.RetrieveAllRoles(); var selected = roleRep.RetrieveRoleById(selectedRole); if (selected.RetrieveRoleId() != 0) { var mapperOne = mapextension.RoleToRoleViewModel(); RoleViewModel model = mapperOne.Map <RoleViewModel>(selected); model.AllRolesInSystem = new List <RoleOverviewViewModel>(); foreach (Role r in roleRep.RetrieveAllRoles()) { var mapperTwo = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapperTwo.Map <RoleOverviewViewModel>(r); model.AllRolesInSystem.Add(rmodel); } return(View("Roleoverview", model)); } return(View("Roleoverview")); }
public RolePermissionViewModel AutoMappingRolePermissionViewModel() { RolePermissionViewModel model = new RolePermissionViewModel(); model.AllPermissionsInSystem = new List <PermissionViewModel>(); model.AllRolesInSystem = new List <RoleOverviewViewModel>(); model.AllRolesWithPermission = new List <RoleOverviewViewModel>(); foreach (Permission p in permissionRep.RetrieveAllPermissions()) { var mapperOne = mapextension.PermissionToPermissionViewModel(); PermissionViewModel pmodel = mapperOne.Map <PermissionViewModel>(p); model.AllPermissionsInSystem.Add(pmodel); } foreach (Role r in roleRep.RetrieveAllRoles()) { var mapperTwo = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapperTwo.Map <RoleOverviewViewModel>(r); model.AllRolesInSystem.Add(rmodel); } return(model); }
public UserRoleViewModel AutoMappingUserRoleViewModel(User selected) { RoleController rc = new RoleController(); var mapper = mapextension.UserToUserRoleViewModel(); UserRoleViewModel model = mapper.Map <UserRoleViewModel>(selected); model.RolesInUser = new List <RoleOverviewViewModel>(); foreach (Role r in rc.RetrieveRolesFromUser(selected)) { var mapperTwo = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapperTwo.Map <RoleOverviewViewModel>(r); model.RolesInUser.Add(rmodel); } model.AllUserRoles = new List <RoleOverviewViewModel>(); foreach (Role r in roleRep.RetrieveAllRoles()) { var mapperThree = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapperThree.Map <RoleOverviewViewModel>(r); model.AllUserRoles.Add(rmodel); } return(model); }