Exemplo n.º 1
0
        public ActionResult Index()
        {
            string             userId      = User.Identity.GetUserId();
            ApplicationUser    currentUser = UserRepository.GetUserById(userId);
            HomeIndexViewModel model       = HomeIndexViewModel.CreateNewViewModel(currentUser, DbContext, 5, 5, 5);

            // Display benchmark data
            if (User.IsInRole(UserRolesEnum.Admin.ToString()))
            {
                FileSystemRepository fileSystemRepository = new FileSystemRepository(Server, FileSystemRepository.BenchmarkFolder);

                //string fileName = $"{Server.MachineName}_Benchmark.json";
                string fileName = CONSTANTS.GetDefaultFileNameForBenchmark(Server);

                (List <ActionResultBenchmark> result, bool hasLoaded, string message) = fileSystemRepository
                                                                                        .LoadJsonFile <List <ActionResultBenchmark> >(fileName);

                if (hasLoaded)
                {
                    ViewBag.BenchmarkResults = result.OrderByDescending(p => p.Created).ToList();
                }

                ViewBag.BenchmarkMessage  = message;
                ViewBag.BenchmarkFileName = fileName;
            }

            return(View(model));
        }