private void OnSortCategoriesByBindingPropertyNameEventRaised(object sender, DataEventArgs sortParameters) { var categoriesDtos = facade.GetCategoriesDto(); switch (sortParameters.ModelDictionary["PropertyName"]) { case "Name": categoriesDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? categoriesDtos.OrderBy(c => c.Name) : categoriesDtos.OrderByDescending(c => c.Name); break; case "SupplierName": categoriesDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? categoriesDtos.OrderBy(c => c.SupplierName) : categoriesDtos.OrderByDescending(c => c.SupplierName); break; case "Link": categoriesDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? categoriesDtos.OrderBy(c => c.Link) : categoriesDtos.OrderByDescending(c => c.Link); break; case "Rate": categoriesDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? categoriesDtos.OrderBy(c => c.Rate) : categoriesDtos.OrderByDescending(c => c.Rate); break; case "Notes": categoriesDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? categoriesDtos.OrderBy(c => c.Notes) : categoriesDtos.OrderByDescending(c => c.Notes); break; } bindingSource.DataSource = categoriesDtos; categoriesUC.SetupControls(bindingSource); }
private void PrepareBindings() { bindingSourceSuppliersIdNameModel = new BindingSource { DataSource = facade.GetSuppliersDto() }; bindingSourceCategoriesIdNameModel = new BindingSource { DataSource = facade.GetCategoriesDto() }; bindingSourceGroupsIdNameModel = new BindingSource { DataSource = facade.GetGroupsDto() }; bindingSourceUnitsIdNameModel = new BindingSource { DataSource = facade.GetUnitsDto() }; }