public void Execute(object parameter) { List <DbModel.Item> Items; using (var context = new DbModel.CodeFirstContext()) { Services.GenericCRUD <DbModel.Item> ItemsCRUD = new Services.GenericCRUD <DbModel.Item>(context); Items = ItemsCRUD.Read(); Console.WriteLine($"{ parameter}"); if (parameter.ToString() == "All") { _VM.Items = Items; } else if (parameter.ToString() == "Assepted") { _VM.Items = (Items.Where(item => item.Category.Name == "Assepted")).ToList <DbModel.Item>(); } else if (parameter.ToString() == "OnStore") { _VM.Items = (Items.Where(item => item.Category.Name == "OnStore")).ToList <DbModel.Item>(); } else if (parameter.ToString() == "Sold") { _VM.Items = (Items.Where(item => item.Category.Name == "Sold")).ToList <DbModel.Item>(); } else if (parameter.ToString() == "DatePeriod") { } } }
public ViewModelBase() { SpawnWindowCommand = new Commands.SpawnWindowCommand(this); FilterGridCommand = new Commands.FilterGridCommand(this); CRUDCommand = new Commands.CRUDCommand(this); using (var context = new DbModel.CodeFirstContext()) { ItemsCRUD = new Services.GenericCRUD <DbModel.Item>(context); this.Items = ItemsCRUD.Read(); CategoriesCRUD = new Services.GenericCRUD <DbModel.Category>(context); this.Categories = CategoriesCRUD.Read(); StoragesCRUD = new Services.GenericCRUD <DbModel.Storage>(context); this.Storages = StoragesCRUD.Read(); //Items.ForEach(i => Console.WriteLine(i.Title)); //Categories.ForEach(i => Console.WriteLine(i.Name)); //Storages.ForEach(i => Console.WriteLine(i.Name)); } }