コード例 #1
0
        public ActionResult Edit(EditAssignmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                _assignmentService.Update(model.Assignment);
                return RedirectToAction("Details", "Assignments", new { id = model.Assignment.Id });
            }

            return RedirectToAction("Edit", new { id = model.Assignment.Id });
        }
コード例 #2
0
        public ActionResult Edit(Guid id)
        {
            var projects = _projectService.GetAllByUserId(User.Identity.GetUserId());
            if (!projects.Any())
            {
                return RedirectToAction("Dashboard", "Manager");
            }

            Assignment assignment = _assignmentService.FindById(id);
            if (assignment == null)
            {
                return HttpNotFound();
            }

            var model = new EditAssignmentViewModel
            {
                Assignment = assignment,
                ListOfProjects = new SelectList(projects, "Id", "Name"),
                ListOfCategories = new SelectList(_dictionaryService.GetCategories(), "Id", "Description"),
                ListOfPriorities = new SelectList(_dictionaryService.GetPriorities(), "Id", "Description"),
                ListOfStatuses = new SelectList(_dictionaryService.GetStatuses(), "Id", "Description"),
                ListOfUsers = new SelectList(_dictionaryService.GetUsers(projects.FirstOrDefault().Id), "Id", "UserName", User.Identity.GetUserId()),
                ListOfSprints = new SelectList(projects.First(x => x.Id == assignment.ProjectId).Sprints, "Id", "Name")
            };

            return View(model);
        }