public static List <Investimento> pesquisar(string nome) { using (var ctx = new InvestimentoContext()) { return(ctx.Investimento.Where(t => t.Nome.Contains(nome)).ToList()); } }
public static Investimento pesquisar(int id) { using (var ctx = new InvestimentoContext()) { return(ctx.Investimento.Find(id)); } }
public static void deletar(int id) { using (var ctx = new InvestimentoContext()) { ctx.Investimento.Remove(ctx.Investimento.Find(id)); ctx.SaveChanges(); } }
public static void cadastrar(Investimento investimento) { using (var ctx = new InvestimentoContext()) { investimento.CotasRestantes = investimento.QtdCotas; ctx.Investimento.Add(investimento); ctx.SaveChanges(); } }
public static void editar(int id, Investimento investimento) { using (var ctx = new InvestimentoContext()) { ctx.Investimento.Find(id).Nome = investimento.Nome; ctx.Investimento.Find(id).Descricao = investimento.Descricao; ctx.Investimento.Find(id).Valor = investimento.Valor; ctx.Investimento.Find(id).Beneficio = investimento.Beneficio; ctx.Investimento.Find(id).QtdCotas = investimento.QtdCotas; ctx.Investimento.Find(id).CotasRestantes = investimento.CotasRestantes; ctx.SaveChanges(); } }
public static List <Investimento> listarComCotas() { try { using (var ctx = new InvestimentoContext()) { return(ctx.Investimento.Where(a => a.CotasRestantes > 0).ToList()); } } catch (Exception) { return(null); }; }
public static List <Investimento> listar() { try { using (var ctx = new InvestimentoContext()) { return(ctx.Investimento.ToList()); } } catch (Exception) { return(null); }; }