private void OnSortGroupsByBindingPropertyNameEventRaised(object sender, DataEventArgs sortParameters) { var groupsDtos = facade.GetGroupsDto(); switch (sortParameters.ModelDictionary["PropertyName"]) { case "Name": groupsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? groupsDtos.OrderBy(g => g.Name) : groupsDtos.OrderByDescending(g => g.Name); break; case "Number": groupsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? groupsDtos.OrderBy(g => g.Number) : groupsDtos.OrderByDescending(g => g.Number); break; case "Identifier": groupsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? groupsDtos.OrderBy(g => g.Identifier) : groupsDtos.OrderByDescending(g => g.Identifier); break; case "AncestorNumber": groupsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? groupsDtos.OrderBy(g => g.AncestorNumber) : groupsDtos.OrderByDescending(g => g.AncestorNumber); break; case "AncestorIdentifier": groupsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? groupsDtos.OrderBy(g => g.AncestorIdentifier) : groupsDtos.OrderByDescending(g => g.AncestorIdentifier); break; case "ProductType": groupsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? groupsDtos.OrderBy(g => g.ProductType) : groupsDtos.OrderByDescending(g => g.ProductType); break; case "Link": groupsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? groupsDtos.OrderBy(g => g.Link) : groupsDtos.OrderByDescending(g => g.Link); break; case "Notes": groupsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? groupsDtos.OrderBy(g => g.Notes) : groupsDtos.OrderByDescending(g => g.Notes); break; } bindingSource.DataSource = groupsDtos; groupsUC.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() }; }