示例#1
0
 public async Task<HttpResponseMessage> PostComposedModel(Guid id, ComposedModelSaveRequest composedModel)
 {
     var model = await _modelRepository.GetComposedModel(id);
     var isNew = model == null;
     await _modelRepository.SaveComposedModel(new ComposedModel
     {
         Id = id,
         Name = composedModel.Name,
         Description = composedModel.Description,
         Sets = composedModel.Sets,
         Parameters = composedModel.Parameters,
         Variables = composedModel.Variables,
         ObjectiveFunction = composedModel.ObjectiveFunction,
         Constraints = composedModel.Constraints,
         LastRevision = isNew ? 1 : model.LastRevision,
     });
     if (isNew)
     {
         var scenario = new Scenario
         {
             Id = Guid.NewGuid(),
             ModelId = id,
             Name = composedModel.Name,
             Description = composedModel.Description,
             Revision = 1,
         };
         await _modelRepository.SaveScenario(scenario);
     }
     return Request.CreateResponse(HttpStatusCode.OK);
 }
示例#2
0
 public ScenarioViewModel(Scenario scenario, bool hasResults)
 {
     Id = scenario.Id;
     ParentScenarioId = scenario.ParentScenarioId;
     ModelId = scenario.ModelId;
     Name = scenario.Name;
     Description = scenario.Description;
     Revision = scenario.Revision;
     HasResults = hasResults;
 }
示例#3
0
 public async Task SaveScenario(Scenario scenario)
 {
     await _scenariosCollection.ReplaceOneAsync(x => x.Id == scenario.Id, scenario, new UpdateOptions
     {
         IsUpsert = true
     });
 }