コード例 #1
0
        public TaskViewModel ToMvcTask(TaskEntity task)
        {
            var user = userMapper.ToMvcUser(userService.GetUserEntity(task.UserId));
            var project = projectService.GetProjectById(task.ProjectId).GetMvcEntity();
            if (user == null || project == null || task == null) throw new NullReferenceException();
            TaskViewModel parentTask = null;
            int id=task.ParentTaskId.GetValueOrDefault();
            if (id!=0)
            {
                parentTask =GetParent(taskService.GetTaskById(id));
            }
            return new TaskViewModel()
            {
                Id = task.Id,
                Deadline = task.Deadline,
                Description = task.Description,
                User = user,
                Project = project,
                isChild = task.isChild,
                Status = (Status)task.StatusId,
                ParentTask = parentTask,
                CompleteProcent=taskService.CompleteProcent(task.Id)
                

            };
        }
コード例 #2
0
 public bool AddSubtask(int parentId,TaskEntity task)
 {
     var parentTask = repository.GetById(parentId);
     if (parentTask == null) return false;
     if (parentTask.Deadline < task.Deadline) return false;
     if (parentTask.isChild == true) return false;
     task.isChild = true;
     task.ProjectId = parentTask.ProjectId;
     task.StatusId = 1;
     task.UserId = parentTask.UserId;
     task.ParentTaskId = parentTask.Id;
     repository.Create(task.ToDalTask());
     return true;
   }
コード例 #3
0
 private TaskViewModel GetParent(TaskEntity task)
 {
     return new TaskViewModel()
     {
         Id = task.Id,
         Deadline = task.Deadline,
         Description = task.Description,
         User = userMapper.ToMvcUser(userService.GetUserEntity(task.UserId)),
         Project = projectService.GetProjectById(task.ProjectId).GetMvcEntity(),
         isChild = task.isChild,
         Status = (Status)task.StatusId,
         ParentTask = null,
         CompleteProcent = taskService.CompleteProcent(task.Id)
         
     };
 }
コード例 #4
0
 public void DeleteTask(TaskEntity task)
 {
     //to do
 }
コード例 #5
0
 public void CreateTask(TaskEntity task)
 {
     repository.Create(task.ToDalTask());
 }