Ejemplo n.º 1
0
        public ActionResult Create(IterationVM iterationVM)
        {
            var iteration = Mapper.Map<IterationVM, Iteration>(iterationVM);
            db.Iterations.Add(iteration);
            db.SaveChanges();

            return RedirectToAction("Index", "TestPlanPerIteration");
        }
Ejemplo n.º 2
0
        public ActionResult Create(int id = 0)
        {
            if (db.Projects.Find(id) == null) return HttpNotFound();
            var iterationVM = new IterationVM
            {
                StartDate = DateTime.Now,
                DueDate = DateTime.Now,
                ProjectID = id
            };

            return View("Create", iterationVM);
        }
        // GET: /TestPlanPerIteration/
        public ActionResult Index(int id = 0)
        {
            UserSettings userSettings = SessionWrapper.UserSettings;

            var iterationVM = new IterationVM
            {
                ProjectID = userSettings.workingProject,
                Project = db.Projects.Find(userSettings.workingProject)
            };

            // No Iteration selected by the user
            if (id == 0)
            {
                var iterationForProject = (from i in db.Iterations
                                           where i.ProjectID == userSettings.workingProject
                                           orderby i.DueDate descending
                                           select i);

                // If there are Iterations created for the project, the first from the list ordered by dueDate is selected as default
                if (iterationForProject.Count() > 0)
                {
                    Iteration iteration = iterationForProject.First();
                    iterationVM = Mapper.Map<Iteration, IterationVM>(iteration);
                }
            }

            // An iteration was selected by the user
            if (id > 0)
            {

                var iterationForProject = from i in db.Iterations
                                          where i.IterationID == id && i.ProjectID == userSettings.workingProject
                                          orderby i.DueDate descending
                                          select i;

                if (iterationForProject.Count() > 0)
                {
                    Iteration iteration = iterationForProject.First();
                    iterationVM = Mapper.Map<Iteration, IterationVM>(iteration);
                }

                // When user is at /TestPlanPerIteration/Index/{id} and there is no such IterationID for the new selected project, redirects to /TestPlanPerIteration
                else
                {
                    return RedirectToAction("Index", new { id = (int?)null });
                }
            }
            return View(iterationVM);
        }
Ejemplo n.º 4
0
        public ActionResult Edit(IterationVM iterationVM)
        {
            var iteration = db.Iterations.Find(iterationVM.IterationID);
            if (iteration == null) return HttpNotFound();
            db.Entry(iteration).CurrentValues.SetValues(iterationVM);
            db.SaveChanges();

            return RedirectToAction("Index", "TestPlanPerIteration", new { id = iteration.IterationID });
        }