예제 #1
0
        private VariableResultSaveRequest CleanUpDefaultData(VariableResultSaveRequest request)
        {
            var defaultValue = request.DefaultValue ?? 0;

            return(new VariableResultSaveRequest
            {
                VariableId = request.VariableId,
                ScenarioId = request.ScenarioId,
                ModelId = request.ModelId,
                DefaultValue = defaultValue,
                Sets = request.Sets,
                Data = request.Data?.Where(d => d.V != defaultValue),
            });
        }
예제 #2
0
 public async Task<HttpResponseMessage> PostVariable(VariableResultSaveRequest request)
 {
     if (request.ScenarioId == Guid.Empty)
     {
         return Request.CreateErrorResponse(HttpStatusCode.UpgradeRequired, "Request no longer supported, please redownload executable file");
     }
     await _resultsRepository.SaveVariableResults(new VariableResult
     {
         VariableId = request.VariableId,
         ScenarioId = request.ScenarioId,
         ModelId = request.ModelId,
         Sets = request.Sets?.Select(s => new VariableSet { Id = s.Id, Index = s.Index }),
         Data = request.Data?.Select(d => new VariableResultItem {C = d.C, V = d.V}),
     });
     return Request.CreateResponse(HttpStatusCode.OK);
 }
예제 #3
0
        public async Task <HttpResponseMessage> PostVariable(VariableResultSaveRequest request)
        {
            if (request.ScenarioId == Guid.Empty)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.UpgradeRequired, "Request no longer supported, please redownload executable file"));
            }
            await _resultsRepository.SaveVariableResults(new VariableResult
            {
                VariableId = request.VariableId,
                ScenarioId = request.ScenarioId,
                ModelId    = request.ModelId,
                Sets       = request.Sets?.Select(s => new VariableSet {
                    Id = s.Id, Index = s.Index
                }),
                Data = request.Data?.Select(d => new VariableResultItem {
                    C = d.C, V = d.V
                }),
            });

            return(Request.CreateResponse(HttpStatusCode.OK));
        }