コード例 #1
0
        // GET: ProjectTasks/Create
        public ActionResult Create(int? projectId)
        {
            ProjectTaskViewModel viewmodel = new ProjectTaskViewModel();
            Project thisproject = db.Projects.Find(projectId);
            viewmodel.ProjectId = thisproject.ProjectId;
            viewmodel.ProjectName = thisproject.Name;

            return View(viewmodel);
        }
コード例 #2
0
        public ActionResult Create(ProjectTaskViewModel viewmodel)
        {
            if (ModelState.IsValid)
            {
                ProjectTask projectTask = new ProjectTask();
                Project thisproject = db.Projects.Find(viewmodel.ProjectId);
                projectTask.Project = thisproject;
                projectTask.Description = viewmodel.Description;
                projectTask.IsComplete = viewmodel.IsComplete;

                db.ProjectTasks.Add(projectTask);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(viewmodel);
        }
コード例 #3
0
 // GET: ProjectTasks/Details/5
 public ActionResult Details(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     ProjectTask projectTask = db.ProjectTasks.Find(id);
     if (projectTask == null)
     {
         return HttpNotFound();
     }
     ProjectTaskViewModel viewmodel = new ProjectTaskViewModel();
     Project thisproject = projectTask.Project;
     viewmodel.ProjectName = thisproject.Name;
     viewmodel.ProjectId = thisproject.ProjectId;
     viewmodel.Description = projectTask.Description;
     viewmodel.IsComplete = projectTask.IsComplete;
     viewmodel.ProjectTaskId = projectTask.ProjectTaskId;
     return View(viewmodel);
 }
コード例 #4
0
        public ActionResult Edit(ProjectTaskViewModel viewmodel)
        {
            if (ModelState.IsValid)
            {
                ProjectTask thisprojecttask = db.ProjectTasks.Find(viewmodel.ProjectTaskId);
                thisprojecttask.Description = viewmodel.Description;
                thisprojecttask.IsComplete = viewmodel.IsComplete;

                db.Entry(thisprojecttask).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("TaskIndexForProject", new { projectId = viewmodel.ProjectId});
            }
            return View(viewmodel);
        }