public async Task <IActionResult> Edit([FromQuery] Guid id, [FromBody] SubtaskPutDto subtaskPutDto)
        {
            if (id != subtaskPutDto.ID)
            {
                return(BadRequest());
            }

            await subtaskService.UpdateAsync(subtaskPutDto);

            return(NoContent());
        }
Example #2
0
        public async Task <bool> UpdateAsync(SubtaskPutDto proPlanPutDto)
        {
            SubtaskPutDtoValidator validator = new SubtaskPutDtoValidator();
            ValidationResult       results   = validator.Validate(proPlanPutDto);

            if (!results.IsValid)
            {
                throw new ValidationException("proPlanPutDTO", string.Join(". ", results.Errors));
            }

            Subtask project = await _repository.GetByIdAsync(proPlanPutDto.ID);

            if (project == null)
            {
                throw new NotFoundException($"The server can not find the requested Subtask with ID: {proPlanPutDto.ID}");
            }

            return(await _repository.UpdateAsync(mapper.Map <Subtask>(proPlanPutDto)) != null);
        }