Example #1
0
 public Product GetProduct(int productId)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         return(ctx.Products.Where(p => p.Id == productId).FirstOrDefault());
     }
 }
Example #2
0
 public Basket GetBasketByOwnId(int id)
 {
     using (var context = new FreeSmokyMarketContext())
     {
         return(context.Baskets.Include(b => b.PurchasesItems).Where(b => b.Id == id).FirstOrDefault());
     }
 }
 public List <Category> GetAllCategories()
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         return(ctx.Categories.ToList());
     }
 }
Example #4
0
 public List <Basket> GetAllBaskets()
 {
     using (var context = new FreeSmokyMarketContext())
     {
         return(context.Baskets.Include(b => b.PurchasesItems).ToList());
     }
 }
Example #5
0
 public Basket GetBasketByOrderId(int orderId)
 {
     using (var context = new FreeSmokyMarketContext())
     {
         return(GetBasketByOwnId(context.Orders.Where(o => o.Id == orderId).FirstOrDefault().BasketId));
     }
 }
Example #6
0
 public Basket GetActiveBasketBySessionId(string sessionId)
 {
     using (var context = new FreeSmokyMarketContext())
     {
         return(context.Baskets.Include(b => b.PurchasesItems).Where(b => b.SessionId == sessionId && b.IsActive == true).FirstOrDefault());
     }
 }
 public Brand GetBrand(int brandId)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         return(ctx.Brands.Where(b => b.Id == brandId).FirstOrDefault());
     }
 }
Example #8
0
 public PurchasesItem GetPurchasesItem(int itemId)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         return(ctx.PurchasesItems.Where(pi => pi.Id == itemId).FirstOrDefault());
     }
 }
Example #9
0
 public Order GetOrder(int orderId)
 {
     using (var context = new FreeSmokyMarketContext())
     {
         return(context.Orders.Where(o => o.Id == orderId).FirstOrDefault());
     }
 }
Example #10
0
 public List <Product> GetAllProducts(int brandId)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         return(ctx.Products.Where(p => p.BrandId == brandId).Where(p => p.Amount > 0).ToList());
     }
 }
Example #11
0
 public List <Order> GetAllOrders()
 {
     using (var context = new FreeSmokyMarketContext())
     {
         return(context.Orders.ToList());
     }
 }
 public void DeleteCategory(Category category)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         ctx.Remove(category);
         ctx.SaveChanges();
     }
 }
 public void CreateCategory(Category category)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         ctx.Add(category);
         ctx.SaveChanges();
     }
 }
Example #14
0
 public void DeletePurchasesItem(PurchasesItem item)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         ctx.PurchasesItems.Remove(item);
         ctx.SaveChanges();
     }
 }
Example #15
0
 public void DeleteOrder(Order order)
 {
     using (var context = new FreeSmokyMarketContext())
     {
         context.Orders.Remove(order);
         context.SaveChanges();
     }
 }
Example #16
0
 public void CreateOrder(Order order)
 {
     using (var context = new FreeSmokyMarketContext())
     {
         context.Orders.Add(order);
         context.SaveChanges();
     }
 }
 public void DeleteBrand(Brand brand)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         ctx.Remove(brand);
         ctx.SaveChanges();
     }
 }
 public void UpdateBrand(Brand brand)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         ctx.Update(brand);
         ctx.SaveChanges();
     }
 }
Example #19
0
 public void UpdateBasket(Basket basket)
 {
     using (var context = new FreeSmokyMarketContext())
     {
         context.Baskets.Update(basket);
         context.SaveChanges();
     }
 }
Example #20
0
 public void CreateProduct(Product product)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         ctx.Add(product);
         ctx.SaveChanges();
     }
 }
Example #21
0
 public void CreatePurchasesItem(PurchasesItem item)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         ctx.PurchasesItems.Add(item);
         ctx.SaveChanges();
     }
 }
Example #22
0
 public void DeleteProduct(Product product)
 {
     using (var ctx = new FreeSmokyMarketContext())
     {
         ctx.Remove(product);
         ctx.SaveChanges();
     }
 }
 public ProductsController(FreeSmokyMarketContext ctx,
                           IProductRepository productRepository,
                           IBrandRepository brandRepository,
                           IReservationService reservationService)
 {
     _productRepository  = productRepository;
     _brandRepository    = brandRepository;
     _reservationService = reservationService;
 }
        public List <Brand> GetAllBrands(int categoryId)
        {
            using (var ctx = new FreeSmokyMarketContext())
            {
                var brandIdHashSet = ctx.Products.Where(p => p.CategoryId == categoryId).Select(p => p.BrandId).ToHashSet();
                var brandList      = new List <Brand>();

                foreach (var el in brandIdHashSet)
                {
                    brandList.Add(GetBrand(el));
                }

                return(brandList);
            }
        }