public List <OutPutGetFormacaoProf> ListaFormacaoProfissional(int id) { using (var db = new FIPEContratosContext()) { try { var lstRetornoFormacaoProfissional = new List <OutPutGetFormacaoProf>(); var lstFormacaoProfissional = new bFormacaoProfissional(db).ListaFormacaoProfissional(); foreach (var form in lstFormacaoProfissional) { var formacaoProfissional = new OutPutGetFormacaoProf(); formacaoProfissional.IdFormacaoProfissional = form.IdFormacaoProfissional; formacaoProfissional.DsFormacaoProfissional = form.DsFormacaoProfissional; lstRetornoFormacaoProfissional.Add(formacaoProfissional); } return(lstRetornoFormacaoProfissional); } catch (Exception ex) { new bEmail(db).EnviarEmailTratamentoErro(ex, "FormacaoProfissionalController-FormacaoProfissionalController"); throw; } } }
public OutPutUpDateFormacaoProfissional Update([FromBody] InputUpDateFormacaoProfissional item) { var retorno = new OutPutUpDateFormacaoProfissional(); using (var db = new FIPEContratosContext()) { var strategy = db.Database.CreateExecutionStrategy(); strategy.Execute(() => { using (var transaction = db.Database.BeginTransaction()) { try { // Inicia transação var formacaoProfissional = new FormacaoProfissional(); formacaoProfissional.IdFormacaoProfissional = item.IdFormacaoProfissional; formacaoProfissional.DsFormacaoProfissional = item.DsFormacaoProfissional; var updateRetorno = new bFormacaoProfissional(db).UpdateFormacaoProfissional(formacaoProfissional); // Confirma operações db.Database.CommitTransaction(); retorno.Result = updateRetorno; return(retorno); } catch (Exception ex) { new bEmail(db).EnviarEmailTratamentoErro(ex, "FormacaoProfissionalController-Update"); retorno.Result = false; } return(retorno); } }); return(retorno); } }
public OutputGetFormacaoProfissionalId GetById(int id) { using (var db = new FIPEContratosContext()) { try { var formacaoProfissional = new OutputGetFormacaoProfissionalId(); var form = new bFormacaoProfissional(db).BuscaFormacaoProfissionalId(id); formacaoProfissional.IdFormacaoProfissional = form.IdFormacaoProfissional; formacaoProfissional.DsFormacaoProfissional = form.DsFormacaoProfissional; return(formacaoProfissional); } catch (Exception ex) { new bEmail(db).EnviarEmailTratamentoErro(ex, "FormacaoProfissionalController-GetById"); throw; } } }