public async Task <IActionResult> put(int codUsuario, MM_Usuario model) { try { var result = await this.Repo.GetAllUsuariosAsyncByCod(codUsuario); if (result == null) { return(BadRequest()); } result.nome = model.nome; result.sobreNome = model.sobreNome; result.senha = model.senha; result.email = model.email; if (await this.Repo.SaveChangesAsync()) { result = await this.Repo.GetAllUsuariosAsyncByCod(codUsuario); return(Ok(result)); } } catch (System.Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } return(BadRequest()); }
public async Task <IActionResult> post(MM_Usuario model) { try { this.Repo.Add(model); if (await this.Repo.SaveChangesAsync()) { var result = await this.Repo.GetAllUsuariosAsyncByCod(model.Id); return(Ok(result)); } } catch { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Falha no acesso ao banco de dados.")); } return(BadRequest()); }