public async Task <IActionResult> PutAsync(int id, [FromBody] SaveEquipamentResource resource) { var equipament = _mapper.Map <SaveEquipamentResource, Equipament>(resource); var result = await _equipamentService.UpdateAsync(id, equipament); if (!result.Success) { return(BadRequest(result.Message)); } var equipamentResource = _mapper.Map <Equipament, EquipamentResource>(result.Resource); return(Ok(equipamentResource)); }
public async Task <IActionResult> PostAsync([FromBody] SaveEquipamentResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetMessages())); } var equipament = _mapper.Map <SaveEquipamentResource, Equipament>(resource); var result = await _equipamentService.SaveAsync(equipament); if (!result.Success) { return(BadRequest(result.Message)); } var equipamentResource = _mapper.Map <Equipament, EquipamentResource>(result.Resource); return(Ok(equipamentResource)); }