public async Task <IActionResult> Save([FromBody] Save_VehicleDTO model) { if (model.Id != 0) { ModelState.AddModelError("id", "Id can´t be assigned manually"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var vehicle = mapper.Map <Save_VehicleDTO, Vehicle>(model); vehicleDAL.AddVehicle(vehicle); dataLayerContext.CompleteChanges(); vehicle = await vehicleDAL.GetVehicleById(vehicle.Id); var vehicleDTO = mapper.Map <Vehicle, VehicleDTO>(vehicle); return(Ok(vehicleDTO)); }
int IVehicleBAL.AddVehicle(Vehicle vehicle) { return(DAL.AddVehicle(vehicle)); }