public OutPutUpDateFundamento Update([FromBody] InputUpDateFundamento item) { var retorno = new OutPutUpDateFundamento(); using (var db = new FIPEContratosContext()) { var strategy = db.Database.CreateExecutionStrategy(); strategy.Execute(() => { using (var transaction = db.Database.BeginTransaction()) { try { // Inicia transação var fund = new FundamentoContratacao(); fund.IdFundamento = item.IdFundamento; fund.DsFundamento = item.DsFundamento; var updateRetorno = new bFundamento(db).UpdateFundamento(fund); // Confirma operações db.Database.CommitTransaction(); retorno.Result = updateRetorno; return(retorno); } catch (Exception ex) { new bEmail(db).EnviarEmailTratamentoErro(ex, "FundamentoController-Update"); retorno.Result = false; } return(retorno); } }); return(retorno); } }
public OutputGetId GetById(int id) { using (var db = new FIPEContratosContext()) { try { var fundamento = new OutputGetId(); var fund = new bFundamento(db).GetById(id); fundamento.IdFundamento = fund.IdFundamento; fundamento.DsFundamento = fund.DsFundamento; return(fundamento); } catch (Exception ex) { new bEmail(db).EnviarEmailTratamentoErro(ex, "FundamentoController-GetById"); throw; } } }
public List <OutputGet> Get() { using (var db = new FIPEContratosContext()) { try { var fundamentos = new bFundamento(db).Get().Select(s => new OutputGet() { IdFundamento = s.IdFundamento, DsFundamento = s.DsFundamento }).OrderBy(o => o.DsFundamento).ToList(); return(fundamentos); } catch (Exception ex) { new bEmail(db).EnviarEmailTratamentoErro(ex, "FundamentoController-Get"); throw; } } }