public async Task <IActionResult> Put(int habilidadeId, HabilidadeDTO model) { try { var habilidade = await this._repo.GetHabilidadeById(habilidadeId); if (habilidade == null) { return(NotFound()); } this._mapper.Map(model, habilidade); this._repo.Update(habilidade); if (await this._repo.SaveChangesAsync()) { return(Ok(this._mapper.Map <HabilidadeDTO>(habilidade))); } } catch (Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } return(BadRequest()); }
public async Task <IActionResult> Post(HabilidadeDTO model) { try { var habilidade = this._mapper.Map <Habilidade>(model); this._repo.Add(habilidade); if (await this._repo.SaveChangesAsync()) { return(Ok(this._mapper.Map <HabilidadeDTO>(habilidade))); } } catch (Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } return(BadRequest()); }