Beispiel #1
0
 public IEnumerable <Purchase> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchaseDbSet.ToList());
     }
 }
Beispiel #2
0
 public IEnumerable <Product> Find(Predicate <Product> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ProductDbSet.Include(i => i.CustomFields.Select(ii => ii.CustomField)).AsEnumerable().Where(p => predicate.Invoke(p)).ToList());
     }
 }
Beispiel #3
0
 public IEnumerable <User> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.UserDbSet.AsEnumerable().ToList());
     }
 }
Beispiel #4
0
 public IEnumerable <Category> Find(Predicate <Category> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CategoryDbSet.Include(i => i.CustomFields).AsEnumerable().Where(c => predicate.Invoke(c)).ToList());
     }
 }
Beispiel #5
0
 public Product GetById(Guid code)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ProductDbSet.Include(i => i.CustomFields.Select(ii => ii.CustomField)).SingleOrDefault(p => p.Code == code));
     }
 }
Beispiel #6
0
 public IEnumerable <ShippingAddress> Find(Predicate <ShippingAddress> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ShippingAddressDbSet.AsEnumerable().Where(sa => predicate.Invoke(sa)).ToList());
     }
 }
Beispiel #7
0
 public Category GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CategoryDbSet.Include(i => i.CustomFields).SingleOrDefault(c => c.Id == id));
     }
 }
Beispiel #8
0
 public IEnumerable <PaymentMethod> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PaymentMethodDbSet.AsEnumerable().ToList());
     }
 }
Beispiel #9
0
 public IEnumerable <PaymentMethod> Find(Predicate <PaymentMethod> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PaymentMethodDbSet.AsEnumerable().Where(p => predicate(p)).ToList());
     }
 }
Beispiel #10
0
 public Role GetById(string name)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.RoleDbSet.Find(name));
     }
 }
Beispiel #11
0
 public PaymentMethod GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PaymentMethodDbSet.Find(id));
     }
 }
Beispiel #12
0
 public IEnumerable <PurchasedProduct> Find(Predicate <PurchasedProduct> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchasedProductDbSet.AsEnumerable().Where(p => predicate.Invoke(p)));
     }
 }
Beispiel #13
0
 public IEnumerable <PurchasedProduct> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchasedProductDbSet.AsEnumerable());
     }
 }
Beispiel #14
0
 public PurchasedProduct GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchasedProductDbSet.Find(id));
     }
 }
Beispiel #15
0
 public ShippingAddress GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ShippingAddressDbSet.Find(id));
     }
 }
Beispiel #16
0
 public Session GetByToken(string token)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.SessionDbSet.Find(token));
     }
 }
Beispiel #17
0
 public IEnumerable <ShippingAddress> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ShippingAddressDbSet.AsEnumerable().ToList());
     }
 }
Beispiel #18
0
 public IEnumerable <Session> Find(Predicate <Session> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.SessionDbSet.AsEnumerable().Where(s => predicate(s)).ToList());
     }
 }
Beispiel #19
0
 public Manufacturer GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ManufacturerDbSet.Find(id));
     }
 }
Beispiel #20
0
 public Review GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ReviewDbSet.Include(i => i.PurchasedProduct).Include(i => i.User).SingleOrDefault(r => r.Id == id));
     }
 }
Beispiel #21
0
 public IEnumerable <Category> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CategoryDbSet.Include(i => i.CustomFields).ToList());
     }
 }
Beispiel #22
0
 public IEnumerable <Review> Find(Predicate <Review> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ReviewDbSet.AsEnumerable().Where(r => predicate.Invoke(r)).ToList());
     }
 }
Beispiel #23
0
        public void Update(Category category)
        {
            using (var dbContext = new SportStoreDbContext())
            {
                var categoryInRepository = dbContext.CategoryDbSet.Include(i => i.CustomFields).SingleOrDefault(c => c.Id == category.Id);

                categoryInRepository.Name        = category.Name;
                categoryInRepository.Description = category.Description;

                foreach (var categoryCustomField in category.CustomFields)
                {
                    var customFieldInRepository = categoryInRepository.CustomFields.SingleOrDefault(cf => cf.Name == categoryCustomField.Name);

                    if (customFieldInRepository != null)
                    {
                        customFieldInRepository.Description = categoryCustomField.Description;
                    }
                    else
                    {
                        categoryInRepository.CustomFields.Add(categoryCustomField);
                    }
                }

                var customFieldsInRepositoryToDelete = categoryInRepository.CustomFields.FindAll(cf => !category.CustomFields.Any(ccf => ccf.Name == cf.Name));

                foreach (var customFieldInRepositoryToDelete in customFieldsInRepositoryToDelete)
                {
                    categoryInRepository.CustomFields.Remove(customFieldInRepositoryToDelete);
                }

                dbContext.SaveChanges();
            }
        }
Beispiel #24
0
 public Review GetByPurchasedProductId(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ReviewDbSet.SingleOrDefault(r => r.PurchasedProduct.Id == id));
     }
 }
Beispiel #25
0
 public IEnumerable <Product> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ProductDbSet.Include(i => i.CustomFields.Select(ii => ii.CustomField)).ToList());
     }
 }
Beispiel #26
0
 public Cart GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CartDbSet.Include(i => i.Products).SingleOrDefault(c => c.Id == id));
     }
 }
Beispiel #27
0
 public User GetById(string userName)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.UserDbSet.Find(userName));
     }
 }
Beispiel #28
0
 public IEnumerable <Cart> Find(Predicate <Cart> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CartDbSet.AsEnumerable().Where(c => predicate.Invoke(c)).ToList());
     }
 }
Beispiel #29
0
 public IEnumerable <User> Find(Predicate <User> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.UserDbSet.AsEnumerable().Where(u => predicate(u)).ToList());
     }
 }
Beispiel #30
0
 public Purchase GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchaseDbSet.SingleOrDefault(p => p.Id == id));
     }
 }