Exemple #1
0
        public async Task <bool> UpdateAsync(UserProjectPutDto proPlanPutDto)
        {
            UserProjectPutDtoValidator validator = new UserProjectPutDtoValidator();
            ValidationResult           results   = validator.Validate(proPlanPutDto);

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

            UserProject project = await userProjectRepository.GetByIdAsync(proPlanPutDto.UserID, proPlanPutDto.ProjectID);

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

            return(await userProjectRepository.UpdateAsync(mapper.Map <UserProject>(proPlanPutDto)) != null);
        }
        public async Task <IActionResult> Edit([FromQuery] Guid userId, [FromQuery] Guid projectId, [FromBody] UserProjectPutDto userProjectPutDto)
        {
            if (userId != userProjectPutDto.UserID || projectId != userProjectPutDto.ProjectID)
            {
                return(BadRequest());
            }

            await userProjectService.UpdateAsync(userProjectPutDto);

            return(NoContent());
        }