public async Task <IActionResult> AddModel([FromBody] ModelResource modelResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var model = mapper.Map <ModelResource, Model>(modelResource); context.Add(model); await context.SaveChangesAsync(); return(Ok(modelResource)); }
public async Task <IActionResult> CreateVehicle([FromBody] VehicleResource vehicleResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var vehicle = mapper.Map <VehicleResource, Vehicle>(vehicleResource); vehicle.LastUpdate = DateTime.Now; context.Add(vehicle); await context.SaveChangesAsync(); return(Ok(vehicle)); }