public IActionResult Get() { var products = productService.GetAllProducts().ToList(); if (products == null) { throw new Exception("No se encontraron productos."); } return(Ok(products)); }
public IActionResult Get() { List <ProductBasicInfoDTO> products = new(); using (NorthwindContext dbContext = new()) { IQueryable <Product> dbProducts = ProductSC.GetAllProducts(dbContext).AsNoTracking(); foreach (Product dbProduct in dbProducts) { products.Add(new ProductBasicInfoDTO(dbProduct)); } ; } return(Ok(products)); }
public IActionResult Get() { var products = productService.GetAllProducts().Select(s => new Product { ProductId = s.ProductId, ProductName = s.ProductName, SupplierId = s.SupplierId, CategoryId = s.CategoryId, QuantityPerUnit = s.QuantityPerUnit, UnitPrice = s.UnitPrice, UnitsInStock = s.UnitsInStock, UnitsOnOrder = s.UnitsOnOrder, ReorderLevel = s.ReorderLevel, Discontinued = s.Discontinued }).ToList(); return(Ok(products)); }
public static void SelectProducts() { var productsQuery = productService.GetAllProducts(); var outPut = productsQuery.ToList(); }
public IActionResult Get() { var products = productsService.GetAllProducts().ToList(); return(Ok(products)); }