protected override DriverResult Editor(ObjectiveResultPart part, IUpdateModel updater, dynamic shapeHelper) { var viewModel = new ObjectiveResultEditorViewModel(); if (updater.TryUpdateModel(viewModel, Prefix, null, new string[] { "Presets" })) { var objective = _objectiveService.Get(viewModel.ObjectiveId, VersionOptions.Latest); if (objective == null) { updater.AddModelError("ObjectiveId", T("Objective not found")); } var team = _teamService.Get(viewModel.TeamId, VersionOptions.Latest); if (team == null) { updater.AddModelError("TeamId", T("Team not found")); } if (objective != null && team != null) { part.Points = viewModel.Points; part.DisplayName = viewModel.DisplayName; part.Team = team.Record; part.Objective = objective.Record; } } return(Editor(part, (object)shapeHelper)); }
private ScoreboardViewModel BuildScoreboardViewModel() { var teams = _teamService.Get().ToList(); var games = _gameService.Get().ToList(); var objectives = _objectiveService.Get().ToList(); //var objectiveResults = _objectiveResultService.Get().Highest().Where(result => Services.Authorizer.Authorize(Permissions.ViewAllResults, result)).ToList(); var objectiveResults = _objectiveResultService.GetHighestResults().Where(result => Services.Authorizer.Authorize(Permissions.ViewAllResults, result)).ToList(); objectiveResults = objectiveResults.Where(o => o.Objective != null && o.Objective.GamePartRecord != null).ToList(); var rankings = from team in teams orderby team.Title ascending select Tuple.Create(team, objectiveResults.Where(result => result.Team.ContentItemRecord.Id == team.ContentItem.Id).Sum(result => result.Points)); rankings = rankings.OrderByDescending(teamScore => teamScore.Item2); var gameRankings = from game in games orderby game.Title ascending select Tuple.Create(game, (from team in teams orderby team.Title ascending select Tuple.Create(team, objectiveResults.Where(result => result.Team.ContentItemRecord.Id == team.ContentItem.Id) .Where(result => game.ContentItem.Id == result.Objective.GamePartRecord.ContentItemRecord.Id) .Sum(result => result.Points))) .OrderByDescending(teamPoints => teamPoints.Item2).AsEnumerable()); return(new ScoreboardViewModel { Rankings = rankings, GameRankings = gameRankings }); }
public async Task <IActionResult> Get(Guid id) { var result = await _service.Get(id); if (result == null) { _log.LogWarning($"Cannot find BusinessModel by id={id}"); return(NotFound($"Cannot find BusinessModel by id={id}")); } return(Ok(result)); }
public IActionResult GetObjective([FromQuery] Guid id) { var model = _objectiveService.Get(id); if (model == null) { throw new ObjectiveNotFoundException($"Objective not found by id {id}"); } Response.Cookies.Append("selectedNodeName", model.Name); return(PartialView("_ObjectiveDetails", model)); }
public ActionResult List(int?objectiveId) { ObjectivePart objective = objectiveId != null?_objectiveService.Get(objectiveId.Value, VersionOptions.Latest) : null; if (objective != null) { var objectiveResults = _objectiveResultService.Get(objective, VersionOptions.Latest); var list = Services.New.List(); list.AddRange(objectiveResults.Select(objectiveResult => Services.ContentManager.BuildDisplay(objectiveResult, "SummaryAdmin"))); dynamic viewModel = Services.New.ViewModel() .ContentItems(list) .Objective(objective); return(View((object)viewModel)); } else { return(HttpNotFound()); } }
public ActionResult List(int?gameId) { GamePart game = null; if (gameId != null) { game = _gameService.Get(gameId.Value, VersionOptions.Latest); } if (game == null) { return(RedirectToAction("ChooseGame")); } IEnumerable <ObjectivePart> objectives; if (game != null) { objectives = _objectiveService.Get(game, VersionOptions.Latest); } else { objectives = _objectiveService.Get(VersionOptions.Latest); } var list = Services.New.List(); list.AddRange(objectives.Select(objective => Services.ContentManager.BuildDisplay(objective, "SummaryAdmin"))); dynamic viewModel = Services.New.ViewModel() .ContentItems(list) .Game(game) .AllGames(_gameService.Get(VersionOptions.Latest)); // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. return(View((object)viewModel)); }
// // GET: /CompetitionPermissionsAdmin/ public ActionResult Index() { var games = _gameService.Get().Where(g => g.Is <CompetitionPermissionsPart>()).ToList(); var objectives = _objectiveService.Get().ToList(); var vm = new ViewModels.CompetitionPermissionsAdminViewModel { Permissions = games.Select(g => Tuple.Create( g, g.As <CompetitionPermissionsPart>(), objectives.Select(o => Tuple.Create( o, o.As <CompetitionPermissionsPart>() )).ToList().AsEnumerable() )).ToList().AsEnumerable() }; return(View(vm)); }