public async Task <bool> UpdateAsync(UserTaskPutDto proPlanPutDto)
        {
            UserTaskPutDtoValidator validator = new UserTaskPutDtoValidator();
            ValidationResult        results   = validator.Validate(proPlanPutDto);

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

            UserTask project = await userTaskRepository.GetByIdAsync(proPlanPutDto.UserID, proPlanPutDto.TaskID);

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

            return(await userTaskRepository.UpdateAsync(mapper.Map <UserTask>(proPlanPutDto)) != null);
        }
Exemple #2
0
        public async Task <IActionResult> Edit([FromQuery] Guid userId, [FromQuery] Guid taskId, [FromBody] UserTaskPutDto userTaskPutDto)
        {
            if (userId != userTaskPutDto.UserID || taskId != userTaskPutDto.TaskID)
            {
                return(BadRequest());
            }

            await userTaskService.UpdateAsync(userTaskPutDto);

            return(NoContent());
        }