public async Task <IActionResult> PutAsync(int id, [FromBody] SaveDriverResource resource) { var driver = _mapper.Map <SaveDriverResource, Driver>(resource); var result = await _driverService.UpdateAsync(id, driver); if (result == null) { return(BadRequest(result.Message)); } var driverResource = _mapper.Map <Driver, DriverResource>(result.Resource); return(Ok(driverResource)); }
public async Task <IActionResult> PostAsync([FromBody] SaveDriverResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var driver = _mapper.Map <SaveDriverResource, Driver>(resource); // TODO: Implement Response Logic var result = await _driverService.SaveAsync(driver); if (!result.Sucess) { return(BadRequest(result.Message)); } var driverResource = _mapper.Map <Driver, DriverResource>(result.Resource); return(Ok(driverResource)); }