public async Task <IActionResult> Post([FromBody] TaskModelDto task)
        {
            task.Id = Guid.Empty;
            task.Id = await _service.AddAsync(task);

            return(CreatedAtAction("Get", new { id = task.Id }, task));
        }
        public async Task <IActionResult> Add([FromBody] TaskViewModel task)
        {
            var user = _context.AppUsers.FirstOrDefault(x => x.Id == _userManager.GetUserId(User));

            task.UserId = user.Id;
            var taskId = await _taskService.AddAsync(task);

            return(Ok(taskId));
        }
Exemple #3
0
        public async Task <ActionResult <TaskModel> > Create(string projectId, TaskDto task)
        {
            var taskModel = _mapper.Map <TaskModel>(task);

            taskModel.ProjectId = projectId;
            taskModel.Id        = Guid.NewGuid().ToString();
            var addedItem = await _taskService.AddAsync(taskModel);

            return(CreatedAtAction(nameof(GetById), new { projectId = addedItem.ProjectId, id = addedItem.Id }, addedItem));
        }
Exemple #4
0
        public async Task <IActionResult> PostTask(AppTaskRequestDto taskRequestDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var taskResponseDto = await _taskService.AddAsync(taskRequestDto);

            return(CreatedAtAction(nameof(GetTask), new { id = taskResponseDto.Id }, taskResponseDto));
        }
Exemple #5
0
        public async Task <ActionResult <Task> > PostTask(CreateTaskDTO task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            TMSTask crearedTask = await _taskService.AddAsync(task);

            return(CreatedAtAction("GetTask", new { id = crearedTask.Id }, crearedTask));
        }
Exemple #6
0
        public async Task <JsonResult> Create(TaskDto taskDto)
        {
            var newTask = await _taskService.AddAsync(taskDto);

            //var result = await _apiClient.AddAsync(taskDto);
            var resultJson = JsonConvert.SerializeObject(newTask);

            _logger.LogInformation($"Added Task: {resultJson}");
            return(Json(resultJson));
        }
Exemple #7
0
        public async Task <IActionResult> Create([FromBody] CreateTaskRequest resource, CancellationToken cancellationToken)
        {
            if (resource == null)
            {
                return(BadRequest());
            }

            await _taskService.AddAsync(resource, cancellationToken);

            return(Ok(resource));
        }
        public async Task <ActionResult <TaskModel> > Post([FromBody] TaskModel taskModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var model = await _service.AddAsync(taskModel);

            return(Ok(new { id = model.Id }));
        }
        public async Task <IActionResult> Create()
        {
            var task = new TaskEntity()
            {
                Status    = Status.created,
                TimeStamp = DateTime.UtcNow
            };

            var id = await _taskService.AddAsync(task);

            return(StatusCode(202, id));
        }
Exemple #10
0
        public async Task <Result <long> > AddAsync(JobTasksInput input)
        {
            var result = await _taskService.AddAsync(input);

            if (result.Success && input.RunNow)
            {
                var start = await _quartzService.StartJobTask(result.Data);

                result.Message      = $"任务创建成功!启动详情:{start.Message} 任务状态:[{start.Data.GetDescription()}]";
                result.ErrorDetail += start.ErrorDetail;
            }
            return(result);
        }
Exemple #11
0
        public async Task <IActionResult> Post([FromBody] TaskDto taskDto, CancellationToken cancellationToken)
        {
            try
            {
                var task = await _taskService.AddAsync(taskDto, cancellationToken);

                return(Ok(task));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #12
0
        public void Setup()
        {
            var contextFactory  = FakeDbContext.Get("Tasks");
            var tasksRepository = new TaskRepository(contextFactory);

            //_taskService = new TaskService(GetTaskRepository(), GetMapper());
            _taskService = new TaskService(tasksRepository, _mapper);

            var createdProject = new CreateTaskRequest
            {
                Name        = _name,
                Id_Project  = _assignedProject,
                Description = _descTask,
                Priority    = _priority,
                Status      = _status
            };

            _taskService.AddAsync(createdProject, CancellationToken.None);
        }
        public async Task <ActionResult <TaskModel> > CreateTask(Guid userId, [FromBody] TaskCreationModel taskCreationModel)
        {
            UserServiceModel user = await _userService.GetByPrincipalAsync(User);

            if (user == null || user.Id != userId)
            {
                return(Unauthorized());
            }

            TaskCreationServiceModel taskCreationServiceModel = _mapper
                                                                .Map <TaskCreationModel, TaskCreationServiceModel>(taskCreationModel);
            TaskServiceModel taskServiceModel = await _taskService.AddAsync(taskCreationServiceModel);

            TaskModel taskModel = _mapper.Map <TaskServiceModel, TaskModel>(taskServiceModel);

            return(CreatedAtAction(nameof(GetTask), new
            {
                taskId = taskModel.Id,
                userId = user.Id
            }, taskModel));
        }
Exemple #14
0
        public async Task <ActionResult> PostAsync(TaskRequest taskRequest)
        {
            if (taskRequest == null)
            {
                return(new BadRequestResult());
            }

            var taskList = await _taskListService.GetByIdAync(taskRequest.TaskListId);

            if (taskList == null)
            {
                return(new BadRequestResult());
            }

            var mappedTask = taskRequest.MapToTaskModel(taskList);

            var task = await _taskService.AddAsync(mappedTask);

            var responseTask = GetTaskResponse(task);

            return(new JsonResult(responseTask));
        }
        public async Task <IActionResult> Add(TaskDto task)
        {
            var newTask = await _taskService.AddAsync(task);

            return(Created(string.Empty, newTask));
        }
        public async Task <IActionResult> Add([FromBody] TaskViewModel task)
        {
            var taskId = await _taskService.AddAsync(task);

            return(Ok(taskId));
        }
        public async Task <ActionResult <TaskGetDto> > PostAsync([FromBody] TaskPostDto taskDto)
        {
            var insertedTask = await _taskService.AddAsync(taskDto);

            return(Ok(insertedTask));
        }
Exemple #18
0
        public async Task <IActionResult> InsertTaskAsync([FromBody] TaskElementDto task)
        {
            var res = await _taskService.AddAsync(task);

            return(Ok(res));
        }
        public async Task <IResult> AddAsync([FromBody] TaskDto dto)
        {
            var result = await _service.AddAsync(dto);

            return(result);
        }
Exemple #20
0
 public async Task HandleAsync(CreateTask command)
 {
     await _taskService.AddAsync(command.Title, command.Description, command.Term, command.Owner);
 }
Exemple #21
0
 public async void Post([FromBody] TaskDomain model)
 {
     await _taskService.AddAsync(model).ConfigureAwait(true);
 }
Exemple #22
0
        public async Task <IActionResult> AddNewTask([FromBody] TaskPostDto taskPostDto)
        {
            var taskResp = await taskService.AddAsync(taskPostDto);

            return(CreatedAtAction("GetTaskById", new { id = taskResp.ID }, mapper.Map <TaskResponseDto>(taskResp)));
        }