Exemplo n.º 1
0
        public ActionResult Edit(TaskInputViewModel task)
        {
            if (ModelState.IsValid)
            {
                var taskModel = task.Map<Task>();

                _taskRepository.Update(taskModel);
                return RedirectToAction("Index", "Home");
            }

            var avaiableProjects = GetAvaiableProjectsForCurrentUser();
            task.AvaiableProjects = avaiableProjects;
            return View(task);
        }
Exemplo n.º 2
0
        public ActionResult Add(TaskInputViewModel task)
        {
            task = CreateUpdateTaskInput(task);
            if (ModelState.IsValid)
            {
                var project = _projectRepository.Load(task.ProjectId);

                var taskModel = task.Map<Task>();

                project.AddTask(taskModel);
                _projectRepository.Save(project);
                return RedirectToAction("Index", "Home");
            }
            return View(task);
        }
Exemplo n.º 3
0
        private TaskInputViewModel CreateUpdateTaskInput(TaskInputViewModel task = null)
        {
            int userId = 1;
            var avaiableProjects = GetAvaiableProjectsForCurrentUser();

            if (task == null)
            {
                task = new TaskInputViewModel
                            {
                                StartTime        = DateTime.Now,
                                AvaiableProjects = avaiableProjects,
                                OwnerId          = userId,
                            };
            }
            else
            {
                task.AvaiableProjects = avaiableProjects;
            }

            return task;
        }