Пример #1
0
 public IEnumerable <Ingrediente> Lista()
 {
     using (var contexto = new LancheContext())
     {
         return(contexto.Ingredientes.ToList());
     }
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
 public IList <Lanche> Lista()
 {
     using (var contexto = new LancheContext())
     {
         return(contexto.Lanches.ToList());
     }
 }
Пример #4
0
 public void Remove(IngredienteLanche ingLanche)
 {
     using (var contexto = new LancheContext())
     {
         contexto.Entry(ingLanche).State = EntityState.Deleted;
         contexto.SaveChanges();
     }
 }
Пример #5
0
 public void Atualiza(IngredienteLanche inglanche)
 {
     using (var contexto = new LancheContext())
     {
         contexto.Entry(inglanche).State = EntityState.Modified;
         contexto.SaveChanges();
     }
 }
Пример #6
0
 public void Adiciona(IngredienteLanche inglanche)
 {
     using (var context = new LancheContext())
     {
         context.IngredienteLanche.Add(inglanche);
         context.SaveChanges();
     }
 }
Пример #7
0
 public void Adiciona(Lanche lanche)
 {
     using (var context = new LancheContext())
     {
         context.Lanches.Add(lanche);
         context.SaveChanges();
     }
 }
Пример #8
0
 public Ingrediente BuscaPorId(int id)
 {
     using (var contexto = new LancheContext())
     {
         return(contexto.Ingredientes
                .Where(p => p.IngredienteId == id)
                .FirstOrDefault());
     }
 }
Пример #9
0
 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());
     }
 }
Пример #10
0
 public IEnumerable <Ingrediente> BuscaPorLancheId(int id)
 {
     using (var contexto = new LancheContext())
     {
         return(contexto.IngredienteLanche
                .Where(x => x.IdLanche == id)
                .Select(x => x.Ingrediente)
                .ToList());
     }
 }
Пример #11
0
        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);
            }
        }