public async Task <IActionResult> PutAsync(int id, [FromBody] SaveBatteryResource resource) { Console.WriteLine("bat1"); if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } Console.WriteLine("bat2"); var battery = _mapper.Map <SaveBatteryResource, Battery>(resource); var result = await _batteryService.UpdateAsync(id, battery); Console.WriteLine("bat3"); if (!result.Success) { return(BadRequest(result.Message)); } Console.WriteLine("bat4"); var batteryResource = _mapper.Map <Battery, BatteryResource>(result.Battery); Console.WriteLine("bat5"); return(Ok(batteryResource)); }
public async Task <IActionResult> PutAsync(int id, [FromBody] SaveBatteryResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } Console.WriteLine(id); Console.WriteLine("^--Put Id"); var battery = _mapper.Map <SaveBatteryResource, Battery>(resource); Console.WriteLine(resource.status); Console.WriteLine("^--Resource Controller Status"); Console.WriteLine(); Console.WriteLine(battery); Console.WriteLine("^--Battery Controller"); Console.WriteLine(); var result = await _batteryService.UpdateAsync(id, battery); if (!result.Success) { return(BadRequest(result.Message)); } var batteryResource = _mapper.Map <Battery, BatteryResource>(result.Battery); return(Ok(batteryResource)); }