Esempio n. 1
0
 public void add_Address(Address address)
 {
     using (var context = new ShopReviewsdb())
     {
         context.Addresses.Add(address);
         context.SaveChanges();
     }
 }
Esempio n. 2
0
 public void add_Shop(Shop shop)
 {
     using (var context = new ShopReviewsdb())
     {
         context.shops.Add(shop);
         context.SaveChanges();
     }
 }
Esempio n. 3
0
 public void add_Review(Review review)
 {
     using (var context = new ShopReviewsdb())
     {
         review.Product = null;
         context.Reviews.Add(review);
         context.SaveChanges();
     }
 }
Esempio n. 4
0
 public void add_Product(Product product)
 {
     using (var context = new ShopReviewsdb())
     {
         product.Shop = null;
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
Esempio n. 5
0
 public void update_Address(Address a)
 {
     using (var context = new ShopReviewsdb())
     {
         var old = context.Addresses.Find(a.AddressID);
         old.AddressID      = a.AddressID;
         old.BuildingNumber = a.BuildingNumber;
         old.City           = a.City;
         old.Street         = a.Street;
         context.SaveChanges();
     }
 }
Esempio n. 6
0
 public void update_Shop(Shop shop)
 {
     using (var context = new ShopReviewsdb())
     {
         var old = context.shops.Find(shop.ShopID);
         update_Address(shop.Address);
         old.Facebook  = shop.Facebook;
         old.ImageURL  = shop.ImageURL;
         old.Instagram = shop.Instagram;
         old.ShopID    = shop.ShopID;
         old.Website   = shop.Website;
         old.Phone     = shop.Phone;
         context.SaveChanges();
     }
 }
Esempio n. 7
0
 public void update_Review(Review r)
 {
     using (var context = new ShopReviewsdb())
     {
         var old = context.Reviews.Find(r.ReviewID);
         old.ProductID       = r.ProductID;
         old.Image           = r.Image;
         old.PublishDate     = r.PublishDate;
         old.Rating          = r.Rating;
         old.ReviewContent   = r.ReviewContent;
         old.ReviewerName    = r.ReviewerName;
         old.ReviewID        = r.ReviewID;
         old.ReviwerBirthday = r.ReviwerBirthday;
         old.ReviwerEmail    = r.ReviwerEmail;
         context.SaveChanges();
     }
 }
Esempio n. 8
0
 public void update_Product(Product p)
 {
     using (var context = new ShopReviewsdb())
     {
         var old = context.Products.Find(p.ProductID);
         old.ProductID         = p.ProductID;
         old.Name              = p.Name;
         old.NutritionalValues = p.NutritionalValues;
         old.Price             = p.Price;
         old.ShopID            = p.ShopID;
         old.SugarFree         = p.SugarFree;
         old.Vegan             = p.Vegan;
         old.ShopID            = p.ShopID;
         old.Description       = p.Description;
         try
         {
             old.GetType().GetProperty("FreeExtras").SetValue(old, p.GetType().GetProperty("FreeExtras").GetValue(p));
         }
         catch (Exception e) { }
         try
         {
             old.GetType().GetProperty("Fat").SetValue(old, p.GetType().GetProperty("Fat").GetValue(p));
         }
         catch (Exception e) { }
         try
         {
             old.GetType().GetProperty("MilkType").SetValue(old, p.GetType().GetProperty("MilkType").GetValue(p));
         }
         catch (Exception e) { }
         try
         {
             old.GetType().GetProperty("Flaver").SetValue(old, p.GetType().GetProperty("Flaver").GetValue(p));
         }
         catch (Exception e) { }
         try
         {
             old.GetType().GetProperty("GlutenFree").SetValue(old, p.GetType().GetProperty("GlutenFree").GetValue(p));
         }
         catch (Exception e) { }
         context.SaveChanges();
     }
 }