Exemple #1
0
        public async Task <ProjectResponseDto> UpdateProject(UpdateProjectRequestDto updateProjectRequestDto, string guid)
        {
            await Task.Delay(10);

            ProjectResponseDto response = _projects.ElementAt(0);

            response.Name        = updateProjectRequestDto.Name;
            response.Description = updateProjectRequestDto.Description;
            response.CreatedBy   = updateProjectRequestDto.CreatedBy;

            return(response);
        }
        public async void UpdateProject_should_return_ProjectResponseDto_dto()
        {
            UpdateProjectRequestDto projectDto = new UpdateProjectRequestDto();

            projectDto.Name        = "Name";
            projectDto.Description = "Description";
            projectDto.CreatedBy   = Guid.Parse("ab2bd817-98cd-4cf3-a80a-53ea0cd9c100");

            var result = await _controller.UpdateProjectById(projectDto, Guid.NewGuid().ToString()) as OkObjectResult;

            var project = Assert.IsType <ProjectResponseDto>(result.Value);

            Assert.Equal(projectDto.Name, project.Name);
            Assert.Equal(projectDto.Description, project.Description);
            Assert.Equal(200, result.StatusCode);
        }
        public async Task <ProjectResponseDto> UpdateProject(UpdateProjectRequestDto updateProjectRequestDto, string guid)
        {
            var project = await _projectRepository.FindProjectById(Utils.checkGuidFormat(guid));

            if (project != null)
            {
                _mapper.Map(updateProjectRequestDto, project);

                if (await _projectRepository.SaveAll())
                {
                    return(_mapper.Map <ProjectResponseDto>(project));
                }
                else
                {
                    _logger.LogError("Something went wront while trying to update project ...");
                    throw new UnknownException("Something went wront while trying to update project.", DomainConsts.APPLICATION_NAME);
                }
            }

            throw new EntityNotFoundException($"{DomainConsts.ENTITY_PROJECT} with id: {guid} not found.", DomainConsts.APPLICATION_NAME);
        }
 public async Task <IActionResult> UpdateProjectById(UpdateProjectRequestDto updateProjectRequestDto, string projectId)
 {
     return(Ok(await _projectService.UpdateProject(updateProjectRequestDto, projectId)));
 }
Exemple #5
0
        public async Task <HttpOperationResult <ProjectDto> > UpdateAsync([FromRoute] Guid id, [FromBody] UpdateProjectRequestDto updateProjectRequestDto)
        {
            logger.LogInformation($"Start execution method '{nameof(UpdateAsync)}'");
            logger.LogInformation($"UpdateProjectRequestDto: '{updateProjectRequestDto}'");

            if (!updateProjectRequestDto.GitUrl.ToString().StartsWith("https://"))
            {
                return(HttpOperationResult <ProjectDto> .BadRequest("Elevator only support git url witch starts with 'https://'"));
            }

            var project = updateProjectRequestDto.ToServiceProject();

            project.Id = id;
            var updated = await projectService.UpdateAsync(project, CurrentUser);

            var resultDto = ModelsMapper.ConvertProjectServiceModelToDtoModel(updated);

            return(HttpOperationResult <ProjectDto> .Ok(resultDto));
        }