Esempio n. 1
0
 public IEnumerable <Purchase> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchaseDbSet.ToList());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 3
0
 public IEnumerable <User> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.UserDbSet.AsEnumerable().ToList());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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));
     }
 }
Esempio n. 6
0
 public IEnumerable <ShippingAddress> Find(Predicate <ShippingAddress> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ShippingAddressDbSet.AsEnumerable().Where(sa => predicate.Invoke(sa)).ToList());
     }
 }
Esempio n. 7
0
 public Category GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CategoryDbSet.Include(i => i.CustomFields).SingleOrDefault(c => c.Id == id));
     }
 }
Esempio n. 8
0
 public IEnumerable <PaymentMethod> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PaymentMethodDbSet.AsEnumerable().ToList());
     }
 }
Esempio n. 9
0
 public IEnumerable <PaymentMethod> Find(Predicate <PaymentMethod> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PaymentMethodDbSet.AsEnumerable().Where(p => predicate(p)).ToList());
     }
 }
Esempio n. 10
0
 public Role GetById(string name)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.RoleDbSet.Find(name));
     }
 }
Esempio n. 11
0
 public PaymentMethod GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PaymentMethodDbSet.Find(id));
     }
 }
Esempio n. 12
0
 public IEnumerable <PurchasedProduct> Find(Predicate <PurchasedProduct> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchasedProductDbSet.AsEnumerable().Where(p => predicate.Invoke(p)));
     }
 }
Esempio n. 13
0
 public IEnumerable <PurchasedProduct> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchasedProductDbSet.AsEnumerable());
     }
 }
Esempio n. 14
0
 public PurchasedProduct GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchasedProductDbSet.Find(id));
     }
 }
Esempio n. 15
0
 public ShippingAddress GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ShippingAddressDbSet.Find(id));
     }
 }
Esempio n. 16
0
 public Session GetByToken(string token)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.SessionDbSet.Find(token));
     }
 }
Esempio n. 17
0
 public IEnumerable <ShippingAddress> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ShippingAddressDbSet.AsEnumerable().ToList());
     }
 }
Esempio n. 18
0
 public IEnumerable <Session> Find(Predicate <Session> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.SessionDbSet.AsEnumerable().Where(s => predicate(s)).ToList());
     }
 }
Esempio n. 19
0
 public Manufacturer GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ManufacturerDbSet.Find(id));
     }
 }
Esempio n. 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));
     }
 }
Esempio n. 21
0
 public IEnumerable <Category> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CategoryDbSet.Include(i => i.CustomFields).ToList());
     }
 }
Esempio n. 22
0
 public IEnumerable <Review> Find(Predicate <Review> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ReviewDbSet.AsEnumerable().Where(r => predicate.Invoke(r)).ToList());
     }
 }
Esempio n. 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();
            }
        }
Esempio n. 24
0
 public Review GetByPurchasedProductId(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ReviewDbSet.SingleOrDefault(r => r.PurchasedProduct.Id == id));
     }
 }
Esempio n. 25
0
 public IEnumerable <Product> All()
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.ProductDbSet.Include(i => i.CustomFields.Select(ii => ii.CustomField)).ToList());
     }
 }
Esempio n. 26
0
 public Cart GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CartDbSet.Include(i => i.Products).SingleOrDefault(c => c.Id == id));
     }
 }
Esempio n. 27
0
 public User GetById(string userName)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.UserDbSet.Find(userName));
     }
 }
Esempio n. 28
0
 public IEnumerable <Cart> Find(Predicate <Cart> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.CartDbSet.AsEnumerable().Where(c => predicate.Invoke(c)).ToList());
     }
 }
Esempio n. 29
0
 public IEnumerable <User> Find(Predicate <User> predicate)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.UserDbSet.AsEnumerable().Where(u => predicate(u)).ToList());
     }
 }
Esempio n. 30
0
 public Purchase GetById(Guid id)
 {
     using (var dbContext = new SportStoreDbContext())
     {
         return(dbContext.PurchaseDbSet.SingleOrDefault(p => p.Id == id));
     }
 }