public async Task <IActionResult> PutAsync(int id, [FromBody] SaveCoordinationResource resource) { var coordination = _mapper.Map <SaveCoordinationResource, Coordination>(resource); var result = await _coordinationService.UpdateAsync(id, coordination); if (!result.Success) { return(BadRequest(new ErrorResource(result.Message))); } var coordinationResource = _mapper.Map <Coordination, CoordinationResource>(result.Resource); return(Ok(coordinationResource)); }
public async Task <IActionResult> PostAsync([FromBody] SaveCoordinationResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var coordination = _mapper.Map <SaveCoordinationResource, Coordination>(resource); var result = await _coordinationService.SaveAsync(coordination); if (!result.Success) { return(BadRequest(result.Message)); } var coordinationResource = _mapper.Map <Coordination, CoordinationResource>(result.Resource); return(Ok(coordinationResource)); }