コード例 #1
0
        public async Task <ActionResult> OnGet()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToPage("/Account/Login", new { area = "Identity" }));
            }
            try
            {
                int?UserGroupID = HttpContext.Session.GetInt32("UserGroupID");
                var user        = await _userManager.GetUserAsync(User);

                PotAccess = await _siteData.GetPotAccess(user.Id.ToString(), UserGroupID);

                int index = PotAccess.FindIndex(item => item.PotID == 1);
                if (index == -1)
                {
                    return(RedirectToPage("/Account/AccessDenied", new { area = "Identity" }));
                }
                Films = _filmData.GetFilmList(UserGroupID).Result;
                var UsersList = _siteData.GetUserList(UserGroupID, 1);
                Users = UsersList.Result;
                var genres    = _filmData.GetGenreList();
                var directors = _filmData.GetDirectorsList();
                var platforms = _filmData.GetPlatformsList();

                UserList = new List <SelectListItem>();
                Genre    = new List <SelectListItem>();
                Director = new List <SelectListItem>();
                Platform = new List <SelectListItem>();

                UsersList.Result.ForEach(x =>
                {
                    UserList.Add(new SelectListItem {
                        Value = x.UserID.ToString(), Text = x.UserName
                    });
                });
                genres.Result.ForEach(x =>
                {
                    Genre.Add(new SelectListItem {
                        Value = x.GenreID.ToString(), Text = x.GenreText
                    });
                });
                directors.Result.ForEach(x =>
                {
                    Director.Add(new SelectListItem {
                        Value = x.DirectorID.ToString(), Text = x.DirectorName
                    });
                });
                platforms.Result.ForEach(x =>
                {
                    Platform.Add(new SelectListItem {
                        Value = x.PlatformID.ToString(), Text = x.PlatformText
                    });
                });

                return(Page());
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                throw new Exception(ex.ToString());
            }
        }