Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 private void SetNav(TestPlan plan)
 {
     ViewBag.Nav = new TestPlanNav(plan);
 }