public void Save(JObject obj) { string type = obj.Properties().ElementAt(0).Name; JObject data = (JObject)obj[type]; Battery b = data.ToObject <Battery>(); Battery battery = batteryRepository.GetBatteryByID(b.Id); if (battery == null) { batteryRepository.InsertBattery(b); } }
public IActionResult Get(int id) { var battery = _batteryRepository.GetBatteryByID(id); return(new OkObjectResult(battery)); }