protected virtual void OnLoaded() { using (var scope = _container.BeginLifetimeScope()) { var db = scope.Resolve <NorthwindDbContext>(); Suppliers.Clear(); Suppliers.AddRange(new ObservableCollection <Supplier>(db.Suppliers .OrderBy(x => x.SupplierId) .AsNoTracking() )); Categories.Clear(); Categories.AddRange(new ObservableCollection <Category>(db.Categories .OrderBy(x => x.CategoryId) .AsNoTracking() )); if (_notification.Id != 0) { var product = db.Products.AsNoTracking().FirstOrDefault(x => x.ProductId == _notification.Id); ProductId.Value = product.ProductId; ProductName.Value = product.ProductName; SupplierId.Value = product.SupplierId; CategoryId.Value = product.CategoryId; QuantityPerUnit.Value = product.QuantityPerUnit; UnitPrice.Value = product.UnitPrice; UnitsInStock.Value = product.UnitsInStock; UnitsOnOrder.Value = product.UnitsOnOrder; ReorderLevel.Value = product.ReorderLevel; Discontinued.Value = product.Discontinued; } } }
public void Fill() { Books.AddRange(Filler.Fill().Books); Clients.AddRange(Filler.Fill().Clients); Suppliers.AddRange(Filler.Fill().Suppliers); Events.AddRange(Filler.Fill().Events); }
private static void LoadFromCsv() { Companies = new List <Company> { Company.Create(Constants.CompanyAId, Constants.CompanyAName), Company.Create(Constants.CompanyBId, Constants.CompanyBName) }; Products = File.ReadLines("..\\..\\..\\..\\input\\catalogA.csv").Skip(1).Select(line => Product.Create(line.Split(',')[0], line.Split(',')[1], Constants.CompanyAId)).ToList(); Products.AddRange(File.ReadLines("..\\..\\..\\..\\input\\catalogB.csv").Skip(1).Select(line => Product.Create(line.Split(',')[0], line.Split(',')[1], Constants.CompanyBId)).ToList()); Suppliers = File.ReadLines("..\\..\\..\\..\\input\\suppliersA.csv").Skip(1).Select(line => Supplier.Create(int.Parse(line.Split(',')[0]), line.Split(',')[1], Constants.CompanyAId)).ToList(); Suppliers.AddRange(File.ReadLines("..\\..\\..\\..\\input\\suppliersB.csv").Skip(1).Select(line => Supplier.Create(int.Parse(line.Split(',')[0]), line.Split(',')[1], Constants.CompanyBId)).ToList()); SupplierProductBarcodes = File.ReadLines("..\\..\\..\\..\\input\\barcodesA.csv").Skip(1).Select(line => SupplierProductBarcode.Create(int.Parse(line.Split(',')[0]), line.Split(',')[1], line.Split(',')[2], Constants.CompanyAId)).ToList(); SupplierProductBarcodes.AddRange(File.ReadLines("..\\..\\..\\..\\input\\barcodesB.csv").Skip(1).Select(line => SupplierProductBarcode.Create(int.Parse(line.Split(',')[0]), line.Split(',')[1], line.Split(',')[2], Constants.CompanyBId)).ToList()); }