public ActionResult AgregarPlatillo(string data)
        {
            _token = Session["Token"].ToString();
            var platilloModel = JsonConvert.DeserializeObject <PlatilloModel>(data);

            Platillo platillo = new Platillo()
            {
                Token         = _token,
                nombre        = platilloModel.Nombre,
                tiempo        = platilloModel.Tiempo,
                precio        = platilloModel.Precio,
                ingredienteId = platilloModel.Ingrediente.Select(i =>
                                                                 new Ingredientes
                {
                    cantidad   = i.Cantidad,
                    productoId = new Productos
                    {
                        id = i.Producto.Id,
                    }
                }).ToList(),
            };

            platillo.CrearPlatillo(platillo);
            return(Json(Url.Action("VerPlatillos", "Platillo")));
        }
Beispiel #2
0
        public void CrearPlatillo()
        {
            ObtenerToken("ADMINISTRADOR", "ASDF");
            var platillo = new Platillo()
            {
                Token         = _token,
                nombre        = "Humita chilena",
                tiempo        = 30,
                ingredienteId = new List <Ingredientes>()
                {
                    new Ingredientes()
                    {
                        cantidad   = 5,
                        productoId = new Productos()
                        {
                            id          = 41,
                            nombre      = "CHOCLO",
                            descripcion = "CHOCLO AMARILLO",
                            cantidad    = 50,
                            precio      = 200,
                            categoria   = "INGREDIENTE"
                        }
                    },
                    new Ingredientes()
                    {
                        cantidad   = 3,
                        productoId = new Productos()
                        {
                            id          = 42,
                            nombre      = "CEBOLLA",
                            descripcion = "CEBOLLA TRADICIONAL",
                            cantidad    = 50,
                            precio      = 500,
                            categoria   = "INGREDIENTE"
                        }
                    }
                }
            };
            var res = platillo.CrearPlatillo(platillo);

            Assert.IsNotNull(res);
        }