Exemplo n.º 1
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))));
        }
Exemplo n.º 2
0
        public async Task <SimulationApiModel> PostAsync(
            [FromBody] SimulationApiModel simulation,
            [FromQuery(Name = "template")] string template = "")
        {
            simulation?.ValidateInputRequest(this.log, this.connectionStringManager);

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

                simulation = new SimulationApiModel();
            }

            return(SimulationApiModel.FromServiceModel(
                       await this.simulationsService.InsertAsync(simulation.ToServiceModel(), template)));
        }