예제 #1
0
        public async Task <IActionResult> Put(int id, [FromBody] VehicleModelRest changeModel)
        {
            if (id != changeModel.VehicleModelId)
            {
                return(BadRequest());
            }

            if (await Service.ModelExists(id))
            {
                await Service.UpdateVehicleModelAsync(id, Mapper.Map <Vehicle.Model.VehicleModel>(changeModel));

                return(Ok());
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] VehicleModelRest newModel)
        {
            await Service.AddVehicleModelAsync(Mapper.Map <Vehicle.Model.VehicleModel>(newModel));

            return(CreatedAtAction(nameof(Get), new { id = newModel.VehicleModelId }, newModel));
        }