예제 #1
0
        public void ProbarCargarIngredientesPorId_IdValida_RegresaIngrediente()
        {
            IngredienteDAO ingredienteDAO = new IngredienteDAO();

            LogicaDeNegocio.Clases.Ingrediente ingrediente = ingredienteDAO.CargarIngredientePorId(1);
            Assert.AreEqual("Tomate", ingrediente.Nombre);
        }
예제 #2
0
        public void ProbarConvertirDeLogicaADatos_IdValida_RegresaIngrediente()
        {
            IngredienteDAO ingredienteDAO = new IngredienteDAO();

            LogicaDeNegocio.Clases.Ingrediente ingrediente = new LogicaDeNegocio.Clases.Ingrediente()
            {
                Id = 1
            };
            LogicaDeNegocio.Clases.Ingrediente ingredienteCargado = ingredienteDAO.CargarIngredientePorId(ingrediente.Id);
            Assert.AreEqual("Tomate", ingredienteCargado.Nombre);
        }
예제 #3
0
        public void AñadirIngredientePorId(int id)
        {
            Ingrediente    ingrediente    = new Ingrediente();
            IngredienteDAO ingredienteDAO = new IngredienteDAO();

            if (!IngredienteYaAñadido(id))
            {
                ingrediente = ingredienteDAO.CargarIngredientePorId(id);
                Proporciones.Add(new Proporcion
                {
                    Ingrediente = ingrediente,
                    Cantidad    = 1
                });
            }
        }
예제 #4
0
        public void CalcularCostoDeIngredientes()
        {
            CostoDeIngredientes = 0;
            List <Proporcion> proporcionesNuevas = new List <Proporcion>();

            foreach (Proporcion proporcion in Proporciones)
            {
                Proporcion     nuevaProporcion = proporcion;
                IngredienteDAO ingredienteDAO  = new IngredienteDAO();
                nuevaProporcion.Ingrediente = ingredienteDAO.CargarIngredientePorId(proporcion.Ingrediente.Id);

                proporcionesNuevas.Add(nuevaProporcion);
            }

            Proporciones = proporcionesNuevas;

            foreach (Proporcion proporcion in Proporciones)
            {
                CostoDeIngredientes += proporcion.Ingrediente.Costo * proporcion.Cantidad;
            }
        }
예제 #5
0
        private void GuardarCambiosButton_Click(object sender, RoutedEventArgs e)
        {
            IngredienteDAO ingredienteDAO = new IngredienteDAO();
            ProductoDAO    productoDAO    = new ProductoDAO();

            foreach (Discrepancia discrepancia in Discrepancias)
            {
                if (discrepancia.TipoDeProducto == TipoDeProducto.Ingrediente)
                {
                    Ingrediente ingrediente = ingredienteDAO.CargarIngredientePorId(discrepancia.Id);
                    ingrediente.CantidadEnInventario = discrepancia.CantidadRegistrada;
                    ingredienteDAO.ActualizarIngrediente(ingrediente);
                }
                else if (discrepancia.TipoDeProducto == TipoDeProducto.Producto)
                {
                    Producto producto = productoDAO.CargarProductoPorID(discrepancia.Id);
                    producto.CantidadEnInventario = (int)discrepancia.CantidadRegistrada;
                    productoDAO.ActualizarProducto(producto);
                }
            }

            MessageBox.Show("Los cambios fueron realizados con exito", "¡Exito¡");
        }