Exemple #1
0
        public ActionResult Index()
        {
            UserIndexViewModel vM = new UserIndexViewModel();
            var isAdmin           = _userRoleService.IsSuperAdmin(User.Identity.Name);

            if (isAdmin)
            {
                vM.UserApps = _userAppService.GetAllUserAppsDistinct();
            }
            else
            {
                var appIds = _userAppService.GetAppIdsWhereAppRoleAdmin(User.Identity.Name);
                var userAppModelsWithOutAppCount = _userAppService.GetUserAppsForAppIds(appIds);

                var userAppModels = new List <UserAppModel>();
                foreach (var item in userAppModelsWithOutAppCount)
                {
                    item.AppCount = _userAppService.CountUserApps(item.BlazerId);
                    userAppModels.Add(item);
                }
                vM.UserApps = userAppModels;
            }

            return(View(vM));
        }
Exemple #2
0
        //Returns list of all Apps from Applist db as Json
        public JsonResult GetAllApps()
        {
            //Logic working before Super Admins
            //List<AppDTO> items = _appServiceAppList.GetAllApps().Select(x => new AppDTO
            //{
            //    id = x.Id,
            //    Text = x.Name
            //}).ToList();
            //return Json(new { items }, JsonRequestBehavior.AllowGet);

            List <AppDTO> items = new List <AppDTO>();

            var isAdmin = _userRoleService.IsSuperAdmin(User.Identity.Name);

            if (isAdmin)
            {
                var appList = _appServiceAppList.GetAllApps();

                foreach (var app in appList)
                {
                    var appDto = new AppDTO
                    {
                        id   = app.Id,
                        Text = app.Name
                    };
                    items.Add(appDto);
                }
            }
            else
            {
                var appList = _appServiceAppList.GrabAdminUserApps(User.Identity.Name);

                foreach (var app in appList)
                {
                    var appDto = new AppDTO
                    {
                        id   = app.Id,
                        Text = app.Name
                    };
                    items.Add(appDto);
                }
            }

            return(Json(new { items }, JsonRequestBehavior.AllowGet));
        }