public async Task <IActionResult> OnPostAsync() { Assignment = await Assignments.FindAsync(Id); if (Assignment == null) { return(NotFound()); } Context.Entry(Assignment).Collection(x => x.Snapshots).Load(); if (!ModelState.IsValid) { return(Page()); } var snapshots = Assignment.Snapshots.ToList(); if (Options.BuildOnly) { snapshots = snapshots.Where(x => x.Report.Type == SnapshotReport.SnapshotReportTypes.Success).ToList(); } if (snapshots.Count < 2) { ModelState.AddModelError("Options.NumberOfStates", "Not enough snapshots"); } if (Options.NumberOfStates >= snapshots.Count) { ModelState.AddModelError("Options.NumberOfStates", "Too many states, not enough snapshots"); } if (!ModelState.IsValid) { return(Page()); } EngineService.RunMarkovModel(Id, Options); return(RedirectToPage("/Analysis/Markov/Index", new { Id })); }