Esempio n. 1
0
        public async Task <bool> Delete(DeleteTaskInput input)
        {
            var task = await _taskRepository.FirstOrDefaultAsync(input.Id);

            if (task == null)
            {
                throw new UserFriendlyException("异常", "任务id不存在");
            }

            await _taskRepository.DeleteAsync(task);

            return(true);
        }
Esempio n. 2
0
        public async Task <IActionResult> Delete(
            [FromServices] IMediator mediator,
            [FromServices] DeleteTaskPresenter presenter,
            [FromBody][Required] DeleteTaskRequest request)
        {
            var accountId = this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "AccountId").Value;

            var input = new DeleteTaskInput(
                new BaseEntityId(new Guid(accountId)),
                new BaseEntityId(request.TableId),
                new BaseEntityId(request.TaskId));

            await mediator.PublishAsync(input);

            return(presenter.ViewModel);
        }
Esempio n. 3
0
 public async System.Threading.Tasks.Task Delete(DeleteTaskInput input)
 {
     try
     {
         var task = _taskRepository.FirstOrDefault(x => x.Id == input.Id);
         if (task == null)
         {
             throw new UserFriendlyException("No Data Found");
         }
         else
         {
             _taskRepository.Delete(task);
         }
     }
     catch (Exception e)
     {
         throw (e);
     }
 }
Esempio n. 4
0
        public DeleteTaskOutput DeleteTask(DeleteTaskInput input)
        {
            var task = _taskRepository.FirstOrDefault(input.Id);

            if (task == null)
            {
                throw new Exception("Can not found the task!");
            }

            var currentUser = _userRepository.Load(AbpUser.CurrentUserId.Value);

            if (!_taskPolicy.CanDeleteTask(currentUser, task))
            {
                throw new UserFriendlyException("You can not delete this task!");
            }

            _taskRepository.Delete(task);

            return(new DeleteTaskOutput());
        }
Esempio n. 5
0
        public async Task Handle(DeleteTaskInput input)
        {
            if (input is null)
            {
                outputPort.WriteError(Message.InputIsNull);
                return;
            }

            try
            {
                var task = await tableRepository.GetTaskAsync(input.TableId, input.AccountId, input.TaskId);

                task.Delete();
                await unitOfWork.Save();

                BuildOutput(task);
            }
            catch (Exception e)
            {
                outputPort.WriteError(e.Message);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 根据TaskId删除任务
 /// </summary>
 /// <param name="input"></param>
 public void DeleteTaskById(DeleteTaskInput input)
 {
     Logger.Info("删除一个任务 for input:" + input);
     _taskRepository.Delete(input.TaskId);
 }