Exemplo n.º 1
0
 public IEnumerable <Product> GetProductOnPromotionBySupplier(int id, int discountId)
 {
     try
     {
         using (var context = new CommunityMarketContext())
         {
             return(context.Products.Where(p => p.DiscountId == discountId && p.SupplierId == id).ToList());
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 2
0
 public IEnumerable <Product> FindAllProductsOnPromotion()
 {
     try
     {
         using (var context = new CommunityMarketContext())
         {
             return(context.Products.Where(p => p.DiscountId != null).ToList());
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 3
0
 public IEnumerable <Product> FindByCategory(int id)
 {
     //throw new NotImplementedException();
     try
     {
         using (var context = new CommunityMarketContext())
         {
             return(context.Products.Where(p => p.ProductCategories.Any(i => i.Id == id)).ToList());
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public IEnumerable <QuickSearchViewModel> Find(string term)
        {
            using (var context = new CommunityMarketContext())
            {
                var products =
                    from product in
                    context.Products.Where(
                        p =>
                        p.ProductName.ToUpper().Contains(term.ToUpper()) ||
                        p.ProductDescLong.ToUpper().Contains(term.ToUpper()) || p.ProductDescShort.ToUpper().Contains(term.ToUpper()))
                    select new QuickSearchViewModel
                {
                    Name   = product.ProductName,
                    Id     = product.Id,
                    ImgUrl = product.ProductImgSmallUrl,
                    Path   = "/Product/ProductDetails/"
                };

                return(products.ToList());
            }
        }
Exemplo n.º 5
0
        public void Add(Product product, ProductCategory category)
        {
            try
            {
                using (var context = new CommunityMarketContext())
                {
                    if (category.Id > 0)
                    {
                        context.Entry(category).State = EntityState.Unchanged;
                    }

                    context.Products.Add(product);
                    context.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                throw;
            }



            //throw new NotImplementedException();
        }
Exemplo n.º 6
0
 public void GetSupplierByProduct(int id)
 {
     using (var context = new CommunityMarketContext())
     {
     }
 }