public async Task <IActionResult> put(int codAvaliacao, MM_Avaliacoes model) { try { var result = await this.Repo.GetAllAvaliacoesAsyncByCod(codAvaliacao); if (result == null) { return(BadRequest()); } result.qtdEstrelas = model.qtdEstrelas; result.mensagem = model.mensagem; result.dataAvaliacao = model.dataAvaliacao; if (await this.Repo.SaveChangesAsync()) { result = await this.Repo.GetAllAvaliacoesAsyncByCod(codAvaliacao); return(Ok(result)); } } catch (System.Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } return(BadRequest()); }
public async Task <IActionResult> post(MM_Avaliacoes model) { try { this.Repo.Add(model); if (await this.Repo.SaveChangesAsync()) { var result = await this.Repo.GetAllAvaliacoesAsyncByCod(model.Id); return(Ok(result)); } } catch (System.Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } return(BadRequest()); }