Exemple #1
0
        public async Task <bool> UpdateTaskByIdAsync(int taskId, TaskDto taskDTO)
        {
            TaskEntity item = await db.Tasks.GetAsync(taskId);

            if (item == null)
            {
                return(false);
            }
            if (!string.IsNullOrEmpty(taskDTO.Name))
            {
                item.Name = taskDTO.Name;
            }
            if (!string.IsNullOrEmpty(taskDTO.Description))
            {
                item.Description = taskDTO.Description;
            }
            item.Private = taskDTO.Private;
            if (taskDTO.ModifierId != null)
            {
                item.Mod_Id = taskDTO.ModifierId;
            }
            await db.Tasks.UpdateAsync(item);

            db.Save();
            return(true);
        }
Exemple #2
0
        public async Task <TaskDto> GetTaskByIdAsync(int taskId)
        {
            TaskEntity taks = await db.Tasks.GetAsync(taskId);

            if (taks == null)
            {
                return(null);
            }
            return(await TaskToTaskDTOAsync(taks));
        }
Exemple #3
0
        public async Task <bool> RemoveTaskByIdAsync(int taskId)
        {
            TaskEntity item = await db.Tasks.GetAsync(taskId);

            if (item != null || await db.Tasks.IsRemovableAsync(taskId))
            {
                await db.Tasks.RemoveAsync(item);

                db.Save();
                return(true);
            }
            return(false);
        }
Exemple #4
0
        public bool CreateTask(TaskDto taskDTO)
        {
            var task = new TaskEntity()
            {
                Name        = taskDTO.Name,
                Description = taskDTO.Description,
                Private     = taskDTO.Private,
                Create_Id   = taskDTO.CreatorId,
                Mod_Id      = taskDTO.ModifierId
            };

            db.Tasks.AddAsync(task);
            db.Save();
            return(true);
        }
Exemple #5
0
        public async Task <TaskDto> GetTaskForPlanAsync(int taskId, int planId)
        {
            TaskEntity task = await db.Tasks.GetAsync(taskId);

            if (task == null)
            {
                return(null);
            }
            var planTask = await db.PlanTasks.Get(taskId, planId);

            if (planTask == null)
            {
                return(null);
            }
            return(await GetTaskForPlanAsync(planTask.Id));
        }
Exemple #6
0
 private async Task <TaskDto> TaskToTaskDTOAsync(TaskEntity task)
 {
     return(new TaskDto(task.Id,
                        task.Name,
                        task.Description,
                        task.Private,
                        task.Create_Id,
                        await db.Users.ExtractFullNameAsync(task.Create_Id),
                        task.Mod_Id,
                        await db.Users.ExtractFullNameAsync(task.Mod_Id),
                        task.Create_Date,
                        task.Mod_Date,
                        null,
                        null,
                        null));
 }
Exemple #7
0
        public async Task <int?> AddAndGetIdAsync(TaskDto taskDTO)
        {
            if (!(await db.Users.ContainsIdAsync(taskDTO.CreatorId)))
            {
                return(null);
            }
            var task = new TaskEntity
            {
                Name        = taskDTO.Name,
                Description = taskDTO.Description,
                Private     = taskDTO.Private,
                Create_Id   = taskDTO.CreatorId,
                Mod_Id      = taskDTO.ModifierId
            };
            var createdTask = db.Tasks.AddAndReturnElement(task);

            db.Save();
            return(createdTask?.Id);
        }
        public async ThreadTask.Task <bool> AddTaskToPlanAsync(int planId, int taskId, int?sectionId, int?priority)
        {
            var plan = await db.Plans.Get(planId);

            if (plan == null)
            {
                return(false);
            }
            LearnWithMentorDAL.Entities.Task task = await db.Tasks.GetAsync(taskId);

            if (task == null)
            {
                return(false);
            }
            await db.Plans.AddTaskToPlanAsync(planId, taskId, sectionId, priority);

            await CreateUserTasksForAllLearningByPlanAsync(planId, taskId);

            db.Save();
            return(true);
        }