示例#1
0
        /// <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));
        }