public ActionResult AddWorkItem(int?id) { var model = new AddWorkItemViewModel(); if (id != null) { model.ProjectID = id; } else { model.ListOfProjectIDs = getAllProjects(); } return(View(model)); }
public ActionResult AddWorkItem(AddWorkItemViewModel newWorkItemViewModel) { if (ModelState.IsValid) { WorkItem newWorkItemEntity = mapper.Map <AddWorkItemViewModel, WorkItem>(newWorkItemViewModel); newWorkItemEntity.IsEnabled = true; newWorkItemEntity.Description = newWorkItemEntity.Description.Parse(); dbContext.WorkItems.Add(newWorkItemEntity); dbContext.SaveChanges(); return(RedirectToAction("Index")); } newWorkItemViewModel.ListOfProjectIDs = getAllProjects(); return(View(newWorkItemViewModel)); }