コード例 #1
0
        public async Task UnmarkSimRun(DependantResourceModel dependantResourceModel)
        {
            var simRunMarkUpdateModel = new SimRunMarkUpdateModel(dependantResourceModel.ResourceId, false);

            var response = await _httpService.PutAsync(
                $"http://{_baseUrl}/simrun/marks",
                simRunMarkUpdateModel
                );

            response.ThrowExceptionIfNotSuccessfulResponseOrNot404Response(
                new FailedToUpdateResourceException(
                    await response.FormatRequestAndResponse(
                        $"Failed to update simRun with id: {dependantResourceModel.ResourceId} from sim-runner-svc!"
                        )
                    )
                );
        }
コード例 #2
0
        public async Task <DependantResourceModel> MarkSimRun(
            SimRunModel simRunModel,
            string projectId
            )
        {
            if (simRunModel.ToBeDeleted)
            {
                throw new ResourceAlreadyMarkedException(
                          $"Cannot mark simRun with id: {simRunModel.Id}, projectId: {projectId}, it is already marked!"
                          );
            }

            var simRunMarkUpdateModel = new SimRunMarkUpdateModel(simRunModel.Id, true);

            var response = await _httpService.PutAsync(
                $"http://{_baseUrl}/simrun/marks",
                simRunMarkUpdateModel
                );

            switch (response.StatusCode)
            {
            case HttpStatusCode.OK:
                return(new DependantResourceModel(ResourceTypeEnum.SimRun, simRunModel.Id));

            case HttpStatusCode.Conflict:
                throw new CannotMarkResourceException(
                          await response.FormatRequestAndResponse(
                              $"Cannot mark simRun with id: {simRunModel.Id}, projectId: {projectId} it must be in state: {SimRunModel.StatusSucceeded}, {SimRunModel.StatusAborted} or {SimRunModel.StatusFailed} beforehand!"
                              )
                          );

            default:
                throw new FailedToUpdateResourceException(
                          await response.FormatRequestAndResponse(
                              $"Failed to update simRun with id: {simRunModel.Id}, projectId: {projectId} from sim-runner-svc!"
                              )
                          );
            }
        }