示例#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);
            }
        }