public DirectionLinkViewModel() { if (!DesignerProperties.IsInDesignTool) { var client = new CRUD_ManagerServiceClient(); Client.GetAllBrandsCompleted += (s, sv) => { BrandsList = sv.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); client.GetGenericCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblLkpDirectionLinkViewModel { Aname = row.Aname, Ename = row.Ename, Iserial = row.Iserial, Code = row.Code }; MainRowList.Add(newrow); } }; lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) => { BrandSectionList.Clear(); foreach (var row in sv.Result) { BrandSectionList.Add(row.TblLkpBrandSection1); } }; lkpClient.GetTblDirectionLinkCompleted += (s, sv) => { MainSelectedRows.Clear(); MainSelectedRows = sv.Result; foreach (var row in MainRowList) { row.UpdatedAllowed = false; row.Checked = false; } foreach (var row in MainSelectedRows) { var familyRow = MainRowList.SingleOrDefault(x => x.Iserial == row.TblLkpDirection); familyRow.Checked = true; } }; client.GetGenericAsync("TblLkpDirection", "%%", "%%", "%%", "Iserial", "ASC"); } }
public FamilyLinkViewModel() { if (!DesignerProperties.IsInDesignTool) { SelectedBrandSection = new TblLkpBrandSectionLinkViewModel(); BrandSectionList = new ObservableCollection <TblLkpBrandSectionLinkViewModel>(); MainRowList = new ObservableCollection <TblFamilyLinkViewModel>(); SelectedMainRow = new TblFamilyLinkViewModel(); SelectedDetailRow = new TblSubFamilyLinkViewModel(); Client.SearchRetailStoresCompleted += (s, sv) => { SelectedBrandSection.Stores = sv.Result; OnStoreCompleted(); }; Client.GetAllBrandsCompleted += (s, sv) => { BrandsList = sv.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); Client.GetGenericCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblLkpBrandSectionLinkViewModel { Aname = row.Aname, Ename = row.Ename, Iserial = row.Iserial, Code = row.Code }; BrandSectionList.Add(newrow); } }; Client.GetGenericAsync("TblLkpBrandSection", "%%", "%%", "%%", "Iserial", "ASC"); lkpClient.GetTblFamilyLinkCompleted += (s, sv) => { MainSelectedRows.Clear(); MainSelectedRows = sv.Result; foreach (var row in MainRowList) { row.UpdatedAllowed = false; row.Checked = false; } foreach (var row in MainSelectedRows) { var familyRow = MainRowList.SingleOrDefault(x => x.Iserial == row.TblFamily); familyRow.Checked = true; } if (_brandCode != null && SelectedBrandSection != null && SelectedMainRow != null) { lkpClient.GetTblSubFamilyLinkAsync(SelectedMainRow.Iserial, BrandCode, SelectedBrandSection.Iserial); } }; lkpClient.GetTblSubFamilyLinkCompleted += (s, sv) => { SubSelectedRows.Clear(); SubSelectedRows = sv.Result; foreach (var row in SelectedMainRow.DetailsList) { row.UpdatedAllowed = false; row.Checked = false; } foreach (var row in SubSelectedRows) { var subfamilyRow = SelectedMainRow.DetailsList.SingleOrDefault(x => x.Iserial == row.TblSubFamily); if (subfamilyRow != null) { subfamilyRow.Checked = true; } } }; lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) => { foreach (var row in BrandSectionList) { row.UpdatedAllowed = false; row.Checked = false; } foreach (var row in sv.Result) { var brandSectionRow = BrandSectionList.SingleOrDefault(x => x.Iserial == row.TblLkpBrandSection ); if (brandSectionRow != null) { brandSectionRow.Checked = true; brandSectionRow.ShortCode = row.ShortCode; brandSectionRow.UseCategory = row.UseCategory; brandSectionRow.UseDirection = row.UseDirection; } } }; lkpClient.GetTblFamilyCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblFamilyLinkViewModel(); newrow.InjectFrom(row); MainRowList.Add(newrow); } Loading = false; FullCount = sv.fullCount; }; lkpClient.GetTblSubFamilyCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblSubFamilyLinkViewModel(); newrow.InjectFrom(row); SelectedMainRow.DetailsList.Add(newrow); } Loading = false; DetailFullCount = sv.fullCount; if (_brandCode != null && SelectedBrandSection != null && SelectedMainRow != null) { lkpClient.GetTblSubFamilyLinkAsync(SelectedMainRow.Iserial, BrandCode, SelectedBrandSection.Iserial); } }; GetMaindata(); } }