Ejemplo n.º 1
0
        public AccesoADatos.RelacionIngrediente ConvertirDeLogicaADatos(Clases.Componente componente)
        {
            RelacionIngrediente componenteDb   = new RelacionIngrediente();
            IngredienteDAO      ingredienteDAO = new IngredienteDAO();

            componenteDb.Cantidad        = componente.Cantidad;
            componenteDb.IngredienteHijo = ingredienteDAO.ConvertirDeLogicaADb(componente.Ingrediente);

            return(componenteDb);
        }
Ejemplo n.º 2
0
        private Clases.Componente ConvertirDeDatosALogica(AccesoADatos.RelacionIngrediente componenteDb)
        {
            Clases.Componente componenteConvertido = new Clases.Componente()
            {
                Cantidad = componenteDb.Cantidad,
            };
            IngredienteDAO ingredienteDAO = new IngredienteDAO();

            componenteConvertido.Ingrediente = ingredienteDAO.ConvertirDeDatosALogica(componenteDb.IngredienteHijo);
            return(componenteConvertido);
        }
Ejemplo n.º 3
0
        private Clases.Proporcion ConvertirProporcionDeAccesoADatosAProporcionDeLogica(AccesoADatos.PlatilloIngrediente proporcionDb)
        {
            IngredienteDAO ingredienteDAO = new IngredienteDAO();

            Clases.Proporcion proporcionConvertida = new Clases.Proporcion
            {
                Id          = proporcionDb.Id,
                Cantidad    = proporcionDb.Cantidad,
                Ingrediente = ingredienteDAO.ConvertirDeDatosALogica(proporcionDb.Ingrediente)
            };

            return(proporcionConvertida);
        }
Ejemplo n.º 4
0
        public List <Clases.Componente> ObtenerComponentesPorIdDeIngredienteCompuesto(int id)
        {
            List <RelacionIngrediente> componentes          = new List <RelacionIngrediente>();
            List <Clases.Componente>   componentesResultado = new List <Clases.Componente>();

            using (ModeloDeDatosContainer context = new ModeloDeDatosContainer())
            {
                componentes = context.RelacionIngredientes.ToList().TakeWhile(objeto => objeto.IngredienteHijo.Id == id).ToList();

                IngredienteDAO ingredienteDAO = new IngredienteDAO();

                componentesResultado = ConvertirListaDeDatosALogica(componentes);
            }

            return(componentesResultado);
        }
Ejemplo n.º 5
0
        public AccesoADatos.PlatilloIngrediente ConvertirLogicaADb(Clases.Proporcion Proporcion)
        {
            AccesoADatos.PlatilloIngrediente proporcionConvertida = new PlatilloIngrediente()
            {
                Id       = Proporcion.Id,
                Cantidad = Proporcion.Cantidad,
            };

            IngredienteDAO ingredienteDAO = new IngredienteDAO();

            proporcionConvertida.Ingrediente = ingredienteDAO.ConvertirDeLogicaADb(Proporcion.Ingrediente);
            proporcionConvertida.Ingrediente.PlatilloIngredientes = new List <PlatilloIngrediente>()
            {
                proporcionConvertida
            };

            return(proporcionConvertida);
        }
Ejemplo n.º 6
0
        public List <Clases.Proporcion> CargarProporcionesPorIdPlatillo(int platilloID)
        {
            List <PlatilloIngrediente> proporcionesDb = new List <PlatilloIngrediente>();

            IngredienteDAO ingredienteDAO = new IngredienteDAO();
            PlatilloDAO    alimentoDAO    = new PlatilloDAO();

            using (ModeloDeDatosContainer context = new ModeloDeDatosContainer())
            {
                proporcionesDb = context.PlatilloIngrediente.Where(p => p.Platillo.Id == platilloID)
                                 .Include(p => p.Platillo)
                                 .Include(p => p.Ingrediente)
                                 .Include(p => p.Ingrediente.RelacionIngredientesHijo)
                                 .ToList();
            }

            return(ConvertirListaDeProporcionesDatosALogica(proporcionesDb));
        }
Ejemplo n.º 7
0
        private AccesoADatos.PlatilloIngrediente ConvertirProporcionDeLogicaAProporcionDeAccesoADatosParaEdicion(Clases.Proporcion Proporcion)
        {
            PlatilloIngrediente proporcionConvertida = new PlatilloIngrediente();

            using (ModeloDeDatosContainer context = new ModeloDeDatosContainer())
            {
                proporcionConvertida = context.PlatilloIngrediente.Find(Proporcion.Id);
            }

            proporcionConvertida.Cantidad = Proporcion.Cantidad;

            IngredienteDAO ingredienteDAO = new IngredienteDAO();

            proporcionConvertida.Ingrediente = ingredienteDAO.ConvertirDeLogicaADb(Proporcion.Ingrediente);
            proporcionConvertida.Ingrediente.PlatilloIngredientes = new List <PlatilloIngrediente>()
            {
                proporcionConvertida
            };

            return(proporcionConvertida);
        }