예제 #1
0
        public IActionResult Index(PaginationOptions options)
        {
            AddEntityListsToViewBag();
            var entities = new PaginatedList <File>(DbContext.Files, options);

            ViewBag.PaginationOptions = options;
            ViewBag.CurrentPage       = options.PageIndex;
            ViewBag.PageCount         = entities.PageCount;

            return(View(FileIndexViewModel.ConvertToViewModels(entities, DbContext)));
        }
예제 #2
0
        public async Task <IActionResult> Index()
        {
            var userId = User.FindFirstValue(ClaimTypes.Name);
            var user   = await _userManager.FindByEmailAsync(userId);

            var roles = await _userManager.GetRolesAsync(user);

            var role = roles.First();

            if (User.Identity.IsAuthenticated)
            {
                if (role == "Manager" || role == "Admin")
                {
                    IEnumerable <FileModel> fileList = _fileService.GetAll();
                    var model = new FileIndexViewModel()
                    {
                        Files = fileList
                    };
                    return(View(model));
                }
                else if (role == "Staff")
                {
                    IEnumerable <FileModel> fileList = _fileService.GetByRole("Staff");
                    var model = new FileIndexViewModel()
                    {
                        Files = fileList
                    };
                    return(View(model));
                }
                else
                {
                    return(NoContent());
                }
            }

            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }