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; } }
public IEnumerable <Product> FindAllProductsOnPromotion() { try { using (var context = new CommunityMarketContext()) { return(context.Products.Where(p => p.DiscountId != null).ToList()); } } catch (Exception) { throw; } }
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()); } }
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(); }
public void GetSupplierByProduct(int id) { using (var context = new CommunityMarketContext()) { } }