Ejemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            string ColumnNamesQuery = @"SELECT * FROM ColumnDefinition WHERE ShortName NOT IN (SELECT [Column] FROM ColumnBlacklist)";

            IEnumerable <ColumnDefinitionModel> ColumnNames = await sql.SelectDataAsync <ColumnDefinitionModel>(ColumnNamesQuery).ConfigureAwait(false);

            List <SelectListItem> ColumnNamesSelectList = ColumnNames.Select(x => new SelectListItem()
            {
                Value = x.FullName, Text = x.FullName
            }).ToList();

            //This section checks if the current user has access to the admin panel
            bool AdminPanelAccess = false;

            Configuration.AdminGroups.ToList().ForEach(group => {
                if (IsInGroup(group))
                {
                    AdminPanelAccess = true;
                }
            });

            Configuration.AdminUsers.ToList().ForEach(user => {
                if (User.Identity.Name.Contains(user))
                {
                    AdminPanelAccess = true;
                }
            });

            return(View(new ArchiveJoinedModel()
            {
                SelectListItems = ColumnNamesSelectList.AsEnumerable(), Data = null, AdminPanelAccess = AdminPanelAccess
            }));
        }