Beispiel #1
0
        //
        // GET: /Projects/5/Tasks/Create

        public ActionResult Create(int pid)
        {
            Task task = new Task
            {
                TaskTypeId = 1,
                TaskStatusId = 1
            };

            ViewBag.TaskTypes = db.TaskTypes.ToList();
            ViewBag.TaskStatuses = db.TaskStatuses.ToList();
            ViewBag.CurrentProject = db.Projects.Find(pid);

            return View(task);
        } 
Beispiel #2
0
        public ActionResult Create(int pid, Task task)
        {
            if (!Request.IsAuthenticated) return RedirectToAction("Create", "Sessions");

            var project = db.Projects.Find(pid);
            task.Project = project;
            task.DateCreated = DateTime.Now;

            if (ModelState.IsValid)
            {
                db.Tasks.Add(task);
                db.SaveChanges();

                TempData["success"] = "Task has successfully been created.";
                return RedirectToAction("Tasks", "Projects", new { id = pid });
            }

            return View(task);
        }