public async Task <SimulationApiModel> PutAsync(
            [FromBody] SimulationApiModel simulation,
            string id = "")
        {
            if (simulation == null)
            {
                this.log.Warn("No data or invalid data provided", () => new { simulation });
                throw new BadRequestException("No data or invalid data provided.");
            }

            return(new SimulationApiModel(
                       await this.simulationsService.UpsertAsync(simulation.ToServiceModel(id))));
        }
Beispiel #2
0
        public async Task <SimulationApiModel> PutAsync(
            [FromBody] SimulationApiModel simulation,
            string id = "")
        {
            simulation?.ValidateInputRequest(this.log, this.connectionStringManager);

            if (simulation == null)
            {
                this.log.Warn("No data or invalid data provided", () => new { simulation });
                throw new BadRequestException("No data or invalid data provided.");
            }

            return(SimulationApiModel.FromServiceModel(
                       await this.simulationsService.UpsertAsync(simulation.ToServiceModel(id))));
        }
        public async Task <SimulationApiModel> PutAsync([FromBody]
                                                        SimulationApiModel simulationApiModel, string id = "")
        {
            if (simulationApiModel == null)
            {
                this.log.Warn("No data provided, request object is null");
                throw new BadRequestException("No data provided, request object is empty.");
            }

            await simulationApiModel.ValidateInputRequestAsync(this.log, this.connectionStringValidation);

            // Load the existing resource, so that internal properties can be copied
            var existingSimulation = await this.GetExistingSimulationAsync(id);

            var simulation = await this.simulationsService.UpsertAsync(simulationApiModel.ToServiceModel(existingSimulation, this.defaultRatingConfig, id));

            return(SimulationApiModel.FromServiceModel(simulation));
        }