Example #1
0
        public async Task <HttpOperationResult <ProjectDto> > GetAsync([FromRoute] Guid id)
        {
            logger.LogInformation($"Start execution method '{nameof(GetAsync)}'. Id = '{id}'");
            var project = await projectService.GetByIdAsync(id, CurrentUser);

            var dtoModel = ModelsMapper.ConvertProjectServiceModelToDtoModel(project);

            return(HttpOperationResult <ProjectDto> .Ok(dtoModel));
        }
Example #2
0
        public async Task <HttpOperationResult <ProjectDto> > CreateAsync([FromBody] CreateProjectRequestDto createProjectRequestDto)
        {
            logger.LogInformation($"Start execution method '{nameof(CreateAsync)}'");
            logger.LogInformation($"CreateProjectRequestDto: '{createProjectRequestDto}'");

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

            var project = await projectService.CreateAsync(createProjectRequestDto.ToServiceProject(), CurrentUser);

            var resultDto = ModelsMapper.ConvertProjectServiceModelToDtoModel(project);

            return(HttpOperationResult <ProjectDto> .Created(resultDto));
        }
Example #3
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));
        }