public AppleHardwareStoreDbContext(DbContextOptions <AppleHardwareStoreDbContext> options) : base(options) { Database.EnsureCreated(); if (!ProductTypes.Any()) { ProductTypes.Add(new ProductType { Name = "Phone" }); ProductTypes.Add(new ProductType { Name = "Laptop" }); SaveChanges(); } if (!Products.Any()) { Products.Add(new Product { Name = "IPhone6", ProductTypeId = ProductTypes.FirstOrDefault(x => x.Name == "Phone").Id, Price = 20000, Description = "128gb, Processor A9, Color SpaceGray, Camera 9mp" }); Products.Add(new Product { Name = "IPhoneXR", ProductTypeId = ProductTypes.FirstOrDefault(x => x.Name == "Phone").Id, Price = 65000, Description = "250gb, Processor A13, Color White, Camera 15mp" }); Products.Add(new Product { Name = "MacBook Pro", ProductTypeId = ProductTypes.FirstOrDefault(x => x.Name == "Laptop").Id, Price = 65000, Description = "SSD - 250gb, RAM - 8gb, Processor - M9, Color - SpaceGray, GPU - AMD Radeon" }); SaveChanges(); } }
public ProductCodeWindowViewModel(SainaDbContext uow) { ProductBrandsDropDownOpenedCommand = new RelayCommand(OnProductBrandsDropDownOpened, () => ProductBrands != null && ProductBrands.Any()); ProductTypesDropDownOpenedCommand = new RelayCommand(OnProductTypesDropDownOpened, () => ProductTypes != null && ProductTypes.Any()); ProductModelsDropDownOpenedCommand = new RelayCommand(OnProductModelsDropDownOpened, () => ProductModels != null && ProductModels.Any()); OtherProductsDropDownOpenedCommand = new RelayCommand(OnOtherProductsDropDownOpened, () => OtherProducts != null && OtherProducts.Any()); _uow = uow; ProductBrands = new ObservableCollection <ProductBrand>(); }