Пример #1
0
        public IActionResult GetMenuPermissions()
        {
            //var config= mapping.GetMap<MenuPermission, MenuPermissionViewModel>();
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <MenuPermission, MenuPermissionViewModel>()
                .ForMember(dest => dest.MenuId, opt => opt.MapFrom(src => src.Menu_MenuId.MenuText))
                .ForMember(dest => dest.RoleId, opt => opt.MapFrom(src => src.Role_RoleId.RoleName))
                .ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.User_UserId.UserName));
            });

            var menuPermission = menuPermissionService.GetAll().ProjectTo <MenuPermissionViewModel>(config).ToList();

            return(Json(new { data = menuPermission }));
        }
        public IActionResult Index()
        {
            DashboardViewModel homeVM = new DashboardViewModel();

            homeVM.User           = _userService.GetAll().Count();
            homeVM.Role           = _roleService.GetAll().Count();
            homeVM.Menu           = _menuService.GetAll().Count();
            homeVM.AppSetting     = _appSettingService.GetAll().Count();
            homeVM.GeneralSetting = _generalSettingService.GetAll().Count();
            homeVM.Notification   = _notificationService.GetAll().Count();
            homeVM.MenuPermission = _menuPermissionService.GetAll().Count();
            homeVM.RoleUser       = _roleUserService.GetAll().Sum(i => i.Id);

            return(View(homeVM));
        }