/// <remarks/> public void GetPartyByGLNAsync(GetPartyByGLN GetPartyByGLN1, object userState) { if ((this.GetPartyByGLNOperationCompleted == null)) { this.GetPartyByGLNOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPartyByGLNOperationCompleted); } this.InvokeAsync("GetPartyByGLN", new object[] { GetPartyByGLN1}, this.GetPartyByGLNOperationCompleted, userState); }
/// <remarks/> public System.IAsyncResult BeginGetPartyByGLN(GetPartyByGLN GetPartyByGLN1, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("GetPartyByGLN", new object[] { GetPartyByGLN1}, callback, asyncState); }
/// <remarks/> public void GetPartyByGLNAsync(GetPartyByGLN GetPartyByGLN1) { this.GetPartyByGLNAsync(GetPartyByGLN1, null); }
private void UpdateDomain(router router, string gtin, itemDataLineType gepirProduct) { if (string.IsNullOrEmpty(gepirProduct.brandName)) { return; } using (var brandRepository = _repositoryFactory.Build <IBrandRepository, Brand>()) { Brand brand = null; var matchingBrands = brandRepository.Find(x => x.BrandName == gepirProduct.brandName); // If a brand with the given name doesn't exist yet, we create it. if (!matchingBrands.Any()) { brand = new Brand { BrandName = gepirProduct.brandName, LastUpdated = DateTime.Now }; brandRepository.Add(brand); } // Else if there exists exactly one brand with the given name we use that brand else if (matchingBrands.Count() == 1) { brand = matchingBrands.First(); // If the brand we retrieved doesn't have an owner we can add it as well if (brand.Owner == null) { var manufacturerGln = gepirProduct.manufacturerGln ?? gepirProduct.informationProviderGln; var getPartyByGln = new GetPartyByGLN { requestedGln = new[] { manufacturerGln }, versionSpecified = false }; var partyByGln = router.GetPartyByGLN(getPartyByGln); if (partyByGln != null && partyByGln.partyDataLine != null && partyByGln.partyDataLine.Length > 0) { using (var companyRepository = _repositoryFactory.Build <IRepository <Company>, Company>()) { var manufacturer = partyByGln.partyDataLine[0]; Company company = null; var matchingCompanies = companyRepository.Find(x => x.CompanyName == manufacturer.partyName); if (!matchingCompanies.Any()) { company = _gepirCompanyMapper.Map(manufacturer); companyRepository.Add(company); companyRepository.Persist(); } else if (matchingCompanies.Count() == 1) { company = matchingCompanies.First(); } // If we added or found the correct company if (company != null) { //Todo: This should actually be done within the repository var brandOwner = brandRepository.FindDomainObject(company); brand.Owner = brandOwner; } brandRepository.Persist(); using (var productRepository = _repositoryFactory.Build <IProductRepository, Product>()) { // If product doesn't exist in database yet - add it. if (!productRepository.Find(x => x.GlobalTradeItemNumber == gtin).Any()) { gepirProduct.gtin = gtin; var newProduct = _gepirProductMapper.Map(gepirProduct); productRepository.Add(newProduct); productRepository.Persist(); } } } } } } if (brand != null && brand.Owner == null) { } } }