public async Task<ActionResult> Create(int testprojectId, TestPlan model, int[] testcases) { var project = model.Project = await _projRepo.FindAsync(testprojectId); if (testcases == null) { ModelState.AddModelError("testcases", "no tests picked for this plan"); } else { model.SetCases(project.Cases.Where(z => testcases.Contains(z.Id))); } if (ModelState.IsValid) { project.Plans.Add(model); await _uow.CommitAsync(); return RedirectToAction("Show", new { id = model.Id, testprojectId }); } SetNav(model); return View("new", model); }
public async Task<ActionResult> Update(int id, int testprojectId, TestPlan model, int[] testcases) { var project = model.Project = await _projRepo.FindAsync(testprojectId); if (testcases == null) { ModelState.AddModelError("testcases", "no tests picked for this plan"); } else { if (ModelState.IsValid) { var entity = project.Plans.First(z => z.Id == id); _planRepo.Merge(entity, model); entity.Cases.Clear(); entity.SetCases(project.Cases.Where(z => testcases.Contains(z.Id))); await _uow.CommitAsync(); return RedirectToAction("Show", new { id, testprojectId }); } } SetNav(model); return View("edit", model); }
private void SetNav(TestPlan plan) { ViewBag.Nav = new TestPlanNav(plan); }