public async Task <IActionResult> PutAsync(int id, [FromBody] SaveTerminalResource resource) { var terminal = _mapper.Map <SaveTerminalResource, Terminal>(resource); var result = await _terminalService.UpdateAssync(id, terminal); if (result == null) { return(BadRequest(result.Message)); } var terminalresource = _mapper.Map <Terminal, TerminalResource>(result.Resource); return(Ok(terminalresource)); }
public async Task <IActionResult> PostAsync([FromBody] SaveTerminalResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var terminal = _mapper.Map <SaveTerminalResource, Terminal>(resource); var result = await _terminalService.SaveAssync(terminal); if (!result.Sucess) { return(BadRequest(result.Message)); } var terminalResource = _mapper.Map <Terminal, TerminalResource>(result.Resource); return(Ok(terminalResource)); }