public async Task <ActionResult <BuildOnStep> > GetFirstBuildOnStep() { BuildOnStep step = await _buildOnsService.GetFirstBuildOnStepAsync(); if (step == null) { return(NotFound()); } return(Ok(step)); }
public async Task <byte[]> GetImageForBuildOnStepAsync(string buildOnStepId) { BuildOnStep buildOnStep = await GetBuildOnStep(buildOnStepId); if (buildOnStep == null || buildOnStep.ImageId == null) { return(null); } return((await _filesService.GetFile(buildOnStep.ImageId)).Data); }
private async Task <BuildOnStep> CreateBuildOnStepAsync(string buildOnId, int index, BuildOnStepManageModel buildOnStepManageModel) { BuildOnStep buildOnStep = new BuildOnStep() { BuildOnId = buildOnId, Index = index, Name = buildOnStepManageModel.Name, Description = buildOnStepManageModel.Description, ReturningType = buildOnStepManageModel.ReturningType, ReturningDescription = buildOnStepManageModel.ReturningDescription, ReturningLink = buildOnStepManageModel.ReturningLink }; await _buildOnSteps.InsertOneAsync(buildOnStep); // We directly update the build-on step to save the image buildOnStep = await UpdateBuildOnStepAsync(buildOnId, buildOnStep.Id, index, buildOnStepManageModel); return(buildOnStep); }
private async Task IncrementProjectBuildOnStep(Project project) { // We need the Builder for the future notification User builderUser = await _buildersService.GetUserFromAdminAsync(project.BuilderId); if (builderUser == null) { throw new Exception("The builder of this project doesn't exist..."); } List <BuildOn> buildOns = await GetAllAsync(); if (buildOns.Count < 1) { throw new Exception("Build-up have no build-ons yet..."); } string newBuildOnId; string newBuildOnStepId; if (project.CurrentBuildOn == null) { newBuildOnId = buildOns.First().Id; var buildOnSteps = await GetAllStepsAsync(buildOns.First().Id); if (buildOnSteps.Count < 1) { return; } newBuildOnStepId = buildOnSteps[1].Id; } else { BuildOn currentBuildOn = await GetBuildOn(project.CurrentBuildOn); BuildOnStep currentStep = await GetBuildOnStep(project.CurrentBuildOnStep); List <BuildOnStep> currentBuildOnSteps = await GetAllStepsAsync(currentBuildOn.Id); // Case 1: we are at the last step of the current build-on if (currentStep.Index == currentBuildOnSteps.Count - 1) { // If we are at the last build-on, no need to continue if (currentBuildOn.Index == buildOns.Count - 1) { newBuildOnId = null; newBuildOnStepId = null; } else { BuildOn newBuildOn = buildOns[currentBuildOn.Index + 1]; List <BuildOnStep> newSteps = await GetAllStepsAsync(newBuildOn.Id); if (newSteps.Count < 1) { return; } newBuildOnId = newBuildOn.Id; newBuildOnStepId = newSteps.First().Id; } } // Case 2: we wan't the next from the current build-on else { newBuildOnId = currentBuildOn.Id; newBuildOnStepId = currentBuildOnSteps[currentStep.Index + 1].Id; } } await _projectsService.UpdateProjectBuildOnStep(project.Id, newBuildOnId, newBuildOnStepId); await _notificationService.NotifyBuildonStepValidated(project.BuilderId, builderUser.Email); }