public RemoveTaskResponse Remove(RemoveTaskRequest request)
        {
            if (request == null)
            {
                return(null);
            }

            var task = this.GetById(request.Id);

            task.Status      = EnumStatusTask.Removed;
            task.RemovedDate = DateTime.Now;

            AddNotifications(task);

            if (this.IsInvalid())
            {
                return(null);
            }

            try
            {
                _repositoryTask.Edit(task);
                return(new RemoveTaskResponse(true));
            }
            catch (Exception ex)
            {
                return(new RemoveTaskResponse(false, ex.Message));
            }
        }
        public async Task <IActionResult> RemoveTask(int id)
        {
            var request = new RemoveTaskRequest {
                Id = id
            };
            var response = await _service.RemoveTask(request);

            return(response.Success ? Ok(response) : StatusCode(404, response.Errors));
        }
        public async Task <RemoveTaskResponse> RemoveTask(RemoveTaskRequest request)
        {
            var response = new RemoveTaskResponse();

            await RunCodeAsync(MethodBase.GetCurrentMethod().Name, request, response, async (uow) =>
            {
                await _manager.RemoveTask(request, response);
            });

            return(response);
        }
Exemple #4
0
 public JsonResult Remove(RemoveTaskRequest request)
 {
     try
     {
         var response = _serviceTask.Remove(request);
         return(Response(response, _serviceTask));
     }
     catch (Exception ex)
     {
         return(ResponseException(ex));
     }
 }
Exemple #5
0
        public async Task RemoveTask(RemoveTaskRequest request, RemoveTaskResponse response)
        {
            await Task.Run(() =>
            {
                var dbTask = _uow.Repository <TaskEntity>().GetDetails(t => t.Id == request.Id);
                if (dbTask != null)
                {
                    var dbXrefBacklogTask = _uow.Repository <XRefBacklogTaskEntity>().GetDetails(x => x.TaskId == request.Id);
                    if (dbXrefBacklogTask != null)
                    {
                        _uow.Repository <XRefBacklogTaskEntity>().Delete(dbXrefBacklogTask);
                    }

                    var dbXRefSprintTasks = _uow.Repository <XRefSprintTaskEntity>().GetOverview(x => x.TaskId == request.Id);
                    if (dbXRefSprintTasks != null && dbXRefSprintTasks.Count() > 0)
                    {
                        _uow.Repository <XRefSprintTaskEntity>().DeleteMany(dbXRefSprintTasks);
                    }

                    _uow.Repository <TaskEntity>().Delete(dbTask);

                    _uow.Save();
                    var backlogItems = GetBacklogTasks(new GetBacklogTasksRequest {
                        TeamId = dbTask.TeamId
                    });
                    if (backlogItems != null && backlogItems.Tasks.Count > 0)
                    {
                        response.Tasks = backlogItems.Tasks;
                    }
                }
                else
                {
                    response.Errors.Add("Sort Backlog items", "Cannot featch Backlog items");
                }
            });
        }