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!"
                              )
                          );
            }
        }
Example #2
0
 public async Task <DependantResourceModel> MarkResultData(
     SimRunModel simRunModel
     )
 {
     return(await MarkResultData(simRunModel.SimulationId));
 }