public IActionResult Users()
        {
            if (!RoleHelper.UserIsAdmin(_database, User))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var identityUsers = _database.AspNetUsers.ToList();
            var userInfos     = new List <UserInfoModel>();

            foreach (var user in identityUsers)
            {
                try
                {
                    userInfos.Add(RoleHelper.GetUserInfo(_database, Guid.Parse(user.Id)));
                }
                catch (Exception ex)
                {
                    LoggingUtil.AddException(ex);
                }
            }

            var viewModel = new UsersViewModel
            {
                UserInfos = _database.UserInfos.ToList(),
                Roles     = _database.Roles.ToList()
            };

            return(View(viewModel));
        }
示例#2
0
        public string GetScorecardName(Guid id)
        {
            try
            {
                return(Scorecards.FirstOrDefault(sc => sc.ID == id).Name);
            }
            catch (Exception ex)
            {
                LoggingUtil.AddException(ex);

                return("");
            }
        }
示例#3
0
        public string GetProgress(Guid id)
        {
            try
            {
                var progress  = ScorecardsInProgress.FirstOrDefault(p => p.ID == id);
                var scorecard = Scorecards.FirstOrDefault(s => s.ID == progress.ScorecardID);

                return(Utils.GetPercentageString(progress.GetResults().Count(), scorecard.Tests.Count()));
            }
            catch (Exception ex)
            {
                LoggingUtil.AddException(ex);

                return("error");
            }
        }
示例#4
0
        public string GetResultsScore(Guid id)
        {
            try
            {
                var results = Results.FirstOrDefault(r => r.ID == id);

                var passed = results.GetTestResults().Where(r => r.Passed == true);

                return(Utils.GetPercentageString(passed.Count(), results.TotalTestCount));
            }
            catch (Exception ex)
            {
                LoggingUtil.AddException(ex);

                return("error");
            }
        }