public async Task <JsonResult> GetInventarioDetallado()
        {
            var lista      = new List <InventarioDetallado>();
            var inventario = await _context.Inventarios.ToListAsync();

            foreach (Inventario inv in inventario)
            {
                var sucursal = await _context.Sucursales.FindAsync(inv.Sucursal);

                var producto = await _context.Productos.FindAsync(inv.Producto);

                var lote = await _context.Lotes.FindAsync(inv.Lote);

                if (producto != null || sucursal != null || lote != null)
                {
                    var proveedor = await _context.Proveedores.FindAsync(producto.Proveedor);

                    var categoria = await _context.CategoriasProductos.FindAsync(producto.CategoriaProducto);

                    var p = new ProductoObj();
                    var i = new InventarioDetallado();
                    p.id                = producto.id;
                    p.Nombre            = producto.Nombre;
                    p.DetallesProveedor = proveedor;
                    p.DetallesCategoria = categoria;
                    p.Descripcion       = producto.Descripcion;
                    i.id                = inv.id;
                    i.Sucursal          = sucursal;
                    i.Producto          = p;
                    i.FechaIngreso      = inv.FechaIngreso;
                    i.Lote              = lote;
                    i.Comentarios       = inv.Comentarios;
                    i.Cantidad          = inv.Cantidad;
                    lista.Add(i);
                }
                else
                {
                    return(new JsonResult(new { mensaje = "Ocurrio un error" }));
                }
            }
            return(new JsonResult(lista));
        }
示例#2
0
        public async Task <JsonResult> GetProducto(int id)
        {
            var producto = await _context.Productos.FindAsync(id);

            if (producto == null)
            {
                return(new JsonResult(new { mensaje = "No se encontro ningún producto con ese id" }));
            }
            var proveedor = await _context.Proveedores.FindAsync(producto.Proveedor);

            var categoria = await _context.CategoriasProductos.FindAsync(producto.CategoriaProducto);

            var prodObj = new ProductoObj();

            prodObj.id                = producto.id;
            prodObj.Nombre            = producto.Nombre;
            prodObj.Descripcion       = producto.Descripcion;
            prodObj.DetallesProveedor = proveedor;
            prodObj.DetallesCategoria = categoria;
            return(new JsonResult(prodObj));
        }
示例#3
0
        public async Task <JsonResult> GetProductos()
        {
            var listaProductos = new List <ProductoObj>();
            var productos      = await _context.Productos.ToListAsync();

            foreach (Producto p in productos)
            {
                var proveedor = await _context.Proveedores.FindAsync(p.Proveedor);

                var categoria = await _context.CategoriasProductos.FindAsync(p.CategoriaProducto);

                var obj = new ProductoObj();
                obj.id                = p.id;
                obj.Nombre            = p.Nombre;
                obj.Descripcion       = p.Descripcion;
                obj.DetallesProveedor = proveedor;
                obj.DetallesCategoria = categoria;
                listaProductos.Add(obj);
            }

            return(new JsonResult(listaProductos));
        }