public IActionResult Create(string id) { string problemName = problemsService.GetProblems().Where(x => x.Id == id).Select(x => x.Name).FirstOrDefault(); if (problemName == null) { return(this.Redirect("/")); } return(this.View(new SubmissionCreationModel { ProblemId = id, ProblemName = problemName })); }
// /Home/Index public IActionResult Index() { if (this.IsLoggedIn()) { var submissions = submissionsService.GetAllSubmissions(); var problems = problemsService.GetProblems() .Select(x => new ProblemViewModel { Id = x.Id, Name = x.Name, Count = submissions.Where(s => s.ProblemId == x.Id).Count() }).ToList(); return(this.View(new ProblemListViewModel { Problems = problems }, "IndexLoggedIn")); } else { return(this.View()); } }
public IActionResult Details(string id) { var submissions = submissionsService.GetSubmissionsById(id) .Select(x => new SubmissionViewModel { Id = x.Id, AchievedResult = x.AchievedResult, MaxPoints = x.Problem.Points, CreatedOn = x.CreatedOn.ToString("dd/MM/yyyy"), Username = x.User.Username }).ToList(); string problemName = problemsService.GetProblems().Where(x => x.Id == id).Select(x => x.Name).FirstOrDefault(); if (problemName == null) { return(this.Redirect("/")); } return(this.View(new SubmissionListViewModel { ProblemName = problemName, Submissions = submissions })); }