public IEnumerable <Ingrediente> Lista() { using (var contexto = new LancheContext()) { return(contexto.Ingredientes.ToList()); } }
public IList <Lanche> ListaCompleto() { using (var context = new LancheContext()) { var lanches = context.Lanches.ToList(); var listLanches = new List <Lanche>(); foreach (var lanche in lanches) { lanche.IngredienteLanches = context.IngredienteLanche.Where(i => i.IdLanche == lanche.LancheId).ToList(); listLanches.Add(lanche); } foreach (var item in listLanches) { foreach (var ingrediente in item.IngredienteLanches) { var ingredienteBD = context.Ingredientes.Where(i => i.IngredienteId == ingrediente.IdIngrediente).FirstOrDefault() ?? new Ingrediente(); ingrediente.Ingrediente.Valor = ingredienteBD.Valor; } } return(listLanches); } }
public IList <Lanche> Lista() { using (var contexto = new LancheContext()) { return(contexto.Lanches.ToList()); } }
public void Remove(IngredienteLanche ingLanche) { using (var contexto = new LancheContext()) { contexto.Entry(ingLanche).State = EntityState.Deleted; contexto.SaveChanges(); } }
public void Atualiza(IngredienteLanche inglanche) { using (var contexto = new LancheContext()) { contexto.Entry(inglanche).State = EntityState.Modified; contexto.SaveChanges(); } }
public void Adiciona(IngredienteLanche inglanche) { using (var context = new LancheContext()) { context.IngredienteLanche.Add(inglanche); context.SaveChanges(); } }
public void Adiciona(Lanche lanche) { using (var context = new LancheContext()) { context.Lanches.Add(lanche); context.SaveChanges(); } }
public Ingrediente BuscaPorId(int id) { using (var contexto = new LancheContext()) { return(contexto.Ingredientes .Where(p => p.IngredienteId == id) .FirstOrDefault()); } }
public IngredienteLanche BuscaPorId(int idIngrediente, int idLanche) { using (var contexto = new LancheContext()) { return(contexto.IngredienteLanche .Where(p => p.IdIngrediente == idIngrediente) .Where(p => p.IdLanche == idLanche) .FirstOrDefault()); } }
public IEnumerable <Ingrediente> BuscaPorLancheId(int id) { using (var contexto = new LancheContext()) { return(contexto.IngredienteLanche .Where(x => x.IdLanche == id) .Select(x => x.Ingrediente) .ToList()); } }
public List <IngredienteLanche> BuscaPorLancheId(int idLanche) { using (var contexto = new LancheContext()) { var ingredienteDAO = new IngredientesDAO(); var listaIngredienteLanche = contexto.IngredienteLanche .Where(p => p.IdLanche == idLanche).ToList(); foreach (var item in listaIngredienteLanche) { item.Ingrediente = ingredienteDAO.BuscaPorId(item.IdIngrediente); } return(listaIngredienteLanche); } }