private void PopulateComboBoxes() { _unitOfWork = new UnitOfWork(_sessionHelper.GetSessionFactory("APL")); Repository<Guid, State> _stateRepo = new Repository<Guid, State>(_unitOfWork.Session); Repository<Guid, APLBackendDB.Region> _regionRepo = new Repository<Guid, APLBackendDB.Region>(_unitOfWork.Session); Repository<Guid, Brand> _brandRepo = new Repository<Guid, Brand>(_unitOfWork.Session); var regions = _regionRepo.All().OrderBy(x => x.Name).ToList(); var states = _stateRepo.All().OrderBy(x => x.Name).ToList(); var brands = _brandRepo.All().OrderBy(x => x.Name).ToList(); _unitOfWork.Dispose(); // Create default dummy selections. APLBackendDB.Region region = new APLBackendDB.Region(); region.Id = Guid.Empty; region.Name = "ALL"; regions.Insert(0, region); cbxRegion.DataSource = regions; cbxRegion.DisplayMember = "name"; cbxRegion.ValueMember = "id"; APLBackendDB.State state = new APLBackendDB.State(); state.Id = Guid.Empty; state.Name = "ALL"; states.Insert(0, state); cbxState.DataSource = states; cbxState.DisplayMember = "name"; cbxState.ValueMember = "id"; APLBackendDB.Brand brand = new APLBackendDB.Brand(); brand.Id = Guid.Empty; brand.Name = "ALL"; brands.Insert(0, brand); cbxBrand.DataSource = brands; cbxBrand.DisplayMember = "name"; cbxBrand.ValueMember = "id"; }
private void PopulateRegionCBX(string defaultRegion) { _unitOfWork = new UnitOfWork(_sessionHelper.GetSessionFactory("APL")); Repository<Guid, APLBackendDB.Region> _regionRepo = new Repository<Guid, APLBackendDB.Region>(_unitOfWork.Session); var x = _regionRepo.All().OrderBy(v => v.Name).ToList(); _unitOfWork.Dispose(); // Create default dummy selection. APLBackendDB.Region region = new APLBackendDB.Region(); region.Id = Guid.Empty; region.Name = "Select..."; x.Insert(0, region); cbxRegion.DataSource = x; cbxRegion.DisplayMember = "name"; cbxRegion.ValueMember = "id"; cbxRegion.SelectedIndex = 0; }