コード例 #1
0
        public async Task <IActionResult> AddProjectCycleTask([FromBody]
                                                              [Bind("projectCycleId", "user", "cycleTaskName", "cycleTaskDescription", "plannedHours", "dueDate")] AddProjectCycleTask cT)
        {
            if (ModelState.IsValid)
            {
                ProjectCycleTask pT = await _projectRepository.AddTaskToCycleAsync(cT);

                if (pT != null)
                {
                    ProjectCycleTask c = new ProjectCycleTask
                    {
                        TaskActive          = pT.TaskActive,
                        TaskDescription     = pT.TaskDescription,
                        TaskName            = pT.TaskName,
                        PlannedHours        = pT.PlannedHours,
                        TaskCompleted       = pT.TaskCompleted,
                        TotalHoursSpent     = pT.TotalHoursSpent,
                        TaskRegistered      = pT.TaskRegistered,
                        TaskDueDate         = pT.TaskDueDate,
                        Unique_TaskIdString = pT.Unique_TaskIdString
                    };
                    return(Ok(c));
                }
                else
                {
                    return(Ok("error"));
                }
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #2
0
        // TODO: Edit all updates correct -ie comleted, active...
        public async Task <bool> EditProjectCycleTaskAsync(EditProjectCycleTask task)
        {
            ProjectCycleTask c = await GetProjectCycleTaskByUniqueId(task.unique_TaskIdString);

            if (task.cycleTaskName != c.TaskName)
            {
                c.TaskName = task.cycleTaskName;
            }
            if (task.cycleTaskDescription != c.TaskDescription)
            {
                c.TaskDescription = task.cycleTaskDescription;
            }
            if (task.plannedHours != c.PlannedHours)
            {
                c.PlannedHours = task.plannedHours;
            }
            if (task.dueDate != c.TaskDueDate)
            {
                c.TaskDueDate = task.dueDate;
            }
            if (task.taskActive != c.TaskActive)
            {
                c.TaskActive = task.taskActive;
            }
            _db.Update(c);
            if (await _db.SaveChangesAsync() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public async Task <ProjectCycleTask> AddTaskToCycleAsync(AddProjectCycleTask cT)
        {
            ProjectCycleTask t = new ProjectCycleTask {
            };

            t.ProjectCycleId = await getProjectCycleId(cT.projectCycleId);

            t.TaskActive          = false;
            t.TaskDescription     = cT.cycleTaskDescription;
            t.TaskName            = cT.cycleTaskName;
            t.PlannedHours        = cT.plannedHours;
            t.TaskCompleted       = false;
            t.TotalHoursSpent     = 0.0;
            t.TaskRegistered      = DateTime.Now;
            t.TaskDueDate         = cT.dueDate;
            t.Unique_TaskIdString = getGuid();

            _db.Add(t);
            if (await _db.SaveChangesAsync() > 0)
            {
                ProjectCycleTask newTaske = await GetProjectCycleTaskByUniqueId(t.Unique_TaskIdString);

                return(newTaske);
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
        public async Task <IActionResult> EditProjectCycleTask([FromRoute] string id)
        {
            ProjectCycleTask c = await _projectRepository.GetProjectCycleTaskByUniqueId(id);

            EditProjectCycleTaskViewModel model = new EditProjectCycleTaskViewModel
            {
                unique_TaskIdString  = c.Unique_TaskIdString,
                cycleTaskName        = c.TaskName,
                cycleTaskDescription = c.TaskDescription,
                plannedHours         = c.PlannedHours,
                dueDate    = c.TaskDueDate,
                taskActive = c.TaskActive
            };

            return(View(model));
        }
コード例 #5
0
        public async Task <IActionResult> ViewProjectCycleTask([FromRoute] string id)
        {
            ProjectCycleTask t = await _projectRepository.GetProjectCycleTaskByUniqueId(id);

            ProjectCycle c = await _projectRepository.GetProjectCycleByUniqueId(t.ProjectCycleId);

            Project p = await _projectRepository.GetProjectByUniqueId(c.ProjectId);

            ViewProjectCycleTaskViewModel model = new ViewProjectCycleTaskViewModel
            {
                ProjectCycleTask = await _projectRepository.GetProjectCycleTaskByUniqueId(id),
                ProjectCycle     = c,
                Project          = p
            };

            return(View(model));
        }
コード例 #6
0
        public async Task <string> DeleteProjectCycleTaskAsync(string unique_id)
        {
            ProjectCycleTask t = await GetProjectCycleTaskByUniqueId(unique_id);

            if (t != null)
            {
                string cycleUniqueId = await getProjectCycleId(t.ProjectCycleTaskId);

                _db.RemoveRange(t);
                if (await _db.SaveChangesAsync() > 0)
                {
                    return(cycleUniqueId);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
        public async Task <ProjectCycleTask> GetProjectCycleTaskByUniqueId(int id)
        {
            ProjectCycleTask task = await _db.ProjectCycleTask.FirstOrDefaultAsync(x => x.ProjectCycleTaskId == id);

            return(task);
        }
コード例 #8
0
        ///////////////                         ///////////////
        ///////////////     ProjectCycleTask    ///////////////
        ///////////////                         ///////////////
        public async Task <ProjectCycleTask> GetProjectCycleTaskByUniqueId(string id)
        {
            ProjectCycleTask task = await _db.ProjectCycleTask.Include("ProjectCycleTaskComments").FirstOrDefaultAsync(x => x.Unique_TaskIdString == id);

            return(task);
        }