예제 #1
0
        public ItemsController(BSaverContext context)
        {
            _dbContext = context;
            if (_dbContext.Items.Count() == 0)
            {
                Vendor[] vendor = { new Vendor {
                                        Id = "78dfbdcb-f1df-4957-a19e-0083fb2f8616", Title = "Carrefour", Desc = "This is Carrefour Hypermarket", VendorLogoPath = "http://bit.ly/carrfqa"
                                    },
                                    new Vendor {
                                        Id = "e9446897-fbd8-4dfc-8610-a2291f6662ec", Title = "Al Meera", Desc = "Al Meera Hypermarket in Qatar", VendorLogoPath = "http://bit.ly/qameera"
                                    } };

                _dbContext.Items.AddRange(new List <Item> {
                    new Item {
                        Id           = "9c21249e-1fcc-4b82-8fd4-48290e36b170", Title = "Potato", Desc = "A description of the staple and how to use or save", Unit = "Kg",
                        UnitPrice    = 13.75, Amount = 1, OfferStartDate = DateTime.Today, Discount = "http://bit.ly/sofferv",
                        OfferEndDate = DateTime.Today, ItemImagePath = "http://bit.ly/ezaypotato", Vendor = vendor[0]
                    },
                    new Item {
                        Id           = "0a5b9aa2-9d8c-4063-8e2a-7c157cd18288", Title = "Onions", Desc = "A description of the staple and how to use or save", Unit = "Pack",
                        UnitPrice    = 9.35, Amount = 1, OfferStartDate = DateTime.Today, Discount = "",
                        OfferEndDate = DateTime.Today, ItemImagePath = "http://bit.ly/onionsqa", Vendor = vendor[0]
                    },
                    new Item {
                        Id           = "376c04bf-861a-4d6e-83c6-7213948809f8", Title = "Milk", Desc = "A description of the staple and how to use or save", Unit = "Ltr",
                        UnitPrice    = 10.50, Amount = 5, OfferStartDate = DateTime.Today, Discount = "http://bit.ly/sofferv",
                        OfferEndDate = DateTime.Today, ItemImagePath = "http://bit.ly/milkbqa", Vendor = vendor[1]
                    }
                });
                _dbContext.SaveChanges();
            }
        }
예제 #2
0
 public VendorsController(BSaverContext context)
 {
     _dbContext = context;
     if (_dbContext.Vendors.Count() == 0)
     {
         _dbContext.Vendors.Add(new Vendor {
             Id = "testVendor", Title = "Carrefour"
         });
         _dbContext.SaveChanges();
     }
 }