Beispiel #1
0
        public async Task <ActionResult> Create(TestVM testVM)
        {
            if (ModelState.IsValid)
            {
                var entity = testVM.ToEntity();

                db.BacklogItems.Add(entity);

                await db.SaveChangesAsync();



                return(RedirectToAction("Index"));
            }

            ViewBag.TestOutcomeId   = new SelectList(db.TestOutcomes, "Id", "Name", testVM.TestOutcomeId);
            ViewBag.VersionOriginId = new SelectList(db.VersionOrigins, "Id", "Name", testVM.VersionOriginId);

            //task
            var sprints = await db.Sprints
                          .Where(s => !s.Erased &&
                                 s.ProjectId == SelectedProjectId)
                          .ToListAsync();

            ViewBag.SprintId = new SelectList(sprints, "Id", "Name", testVM.SprintId);

            var team = await db.Teams
                       .Include(t => t.TeamMembers)
                       .Include("TeamMembers.User")
                       .FirstOrDefaultAsync(t => !t.Erased &&
                                            t.ProjectId == SelectedProjectId);

            List <User> users = new List <User>();

            if (team != null)
            {
                users = team.TeamMembers
                        .Where(m => !m.Erased)
                        .Select(tm => tm.User).ToList();
            }

            ViewBag.UserId = new SelectList(users, "Id", "FullName", testVM.UserId);
            return(View(testVM));
        }