Пример #1
0
        public async Task <IActionResult> CreateProjectAsync([FromBody] CreateProjectRequest request, [FromServices] ICreateProjectCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ProjectResponse response = await command.ExecuteAsync(request);

            return(Ok(response)); // This is wrong, it should return 401
        }
Пример #2
0
        public async Task <IActionResult> CreateProjectAsync([FromBody] CreateProjectRequest request, [FromServices] ICreateProjectCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string          user     = User.Identity.Name;
            ProjectResponse response = await command.ExecuteAsync(request, user);

            return(Created(Url.RouteUrl(new { response.Id }), response));
        }
Пример #3
0
        public async Task <IActionResult> CreateProjectAsync([FromBody] CreateProjectRequest request, [FromServices] ICreateProjectCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var             userId   = HttpContext.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier).Value;
            ProjectResponse response = await command.ExecuteAsync(request, userId);

            return(CreatedAtRoute("GetSingleProject", new { projectId = response.Id }, response));
        }
        public async Task <CreateTeamCitySolutionResponse> ExecuteAsync(CreateSolutionModel model, Action <CreateSolutionModel, string> notifyAction)
        {
            notifyAction(model, "Teamcity build started");
            Project parentProject;

            await _createVisualStudioSolutionCommand.ExecuteAsync(model, notifyAction);

            // Create Main Project
            if (model.NewParentProject)
            {
                var mainProjectModel = _modelFactory.Create(model.TeamCityNewParentProjectName);
                parentProject = await _createProjectCommand.ExecuteAsync(mainProjectModel);
            }
            else
            {
                parentProject = await _getProjectQuery.Execute(model.TeamCityParentProjectId);
            }

            // Create Sub Project
            var subProjectModel = _modelFactory.Create(model.TeamCitySubprojectName, parentProject.Id);

            var subProject = await _createProjectCommand.ExecuteAsync(subProjectModel);

            // Create Build
            var build = await _createBuildCommand.ExecuteAsync(subProject.Id);

            var param = await _updateBuildParameterCommand.Execute(build, "SolutionName", model.VisualStudioSolutionName);

            // Create VCS Root and attach to build
            var vcsModel = _vcsModelFactory.Create(model.TeamCitySubprojectName + " master", subProject.Id, model.SourceControlUrl);
            var vcs      = await _createVcsRootCommand.Execute(vcsModel, build.Id);

            notifyAction(model, "Teamcity build complete");

            return(new CreateTeamCitySolutionResponse()
            {
                ParentProject = parentProject,
                SubProject = subProject,
                TypVcsRoot = vcs
            });
        }
Пример #5
0
        public async Task <IActionResult> CreateProjectAsync([FromBody] CreateProjectRequest request, [FromServices] ICreateProjectCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                ProjectResponse response = await command.ExecuteAsync(request);

                return(Ok(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }