public async Task <IActionResult> PutAsync(int id, [FromBody] SaveExampleSubClassResource resource) { //Same as POST var exampleSubClass = _mapper.Map <SaveExampleSubClassResource, ExampleSubClass>(resource); //Diferent from POST var result = await _exampleSubClassService.UpdateAsync(id, exampleSubClass); if (!result.Succes) { return(BadRequest(result.Message)); } var exampleSubClassResource = _mapper.Map <ExampleSubClass, ExampleSubClassResource>(result.Resource); return(Ok(exampleSubClassResource)); }
public async Task <IActionResult> PostAsync([FromBody] SaveExampleSubClassResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var exampleSubClass = _mapper.Map <SaveExampleSubClassResource, ExampleSubClass>(resource); var result = await _exampleSubClassService.SaveAsync(exampleSubClass); if (!result.Succes) { return(BadRequest(result.Message)); } var exampleSubClassResource = _mapper.Map <ExampleSubClass, ExampleSubClassResource>(result.Resource); return(Ok(exampleSubClassResource)); }