コード例 #1
0
        private CompanyLocationModel MapFromAmdModel(AmdService.Model.CompanyLocation amdModel, Microsoft.OData.Client.DataServiceQuery <AmdService.Model.State> deepStatesResponse)
        {
            //CompanyLocation model implementation
            CompanyLocationModel model = new CompanyLocationModel();

            model.LocationId        = amdModel.Id;
            model.AbacusCode        = amdModel.Company?.AbacusCode;
            model.AddressId         = amdModel.AddressId;
            model.LocationType      = amdModel.AddressType?.Name;
            model.CountryHq         = amdModel.CountryHeadQuarter;
            model.Phone             = amdModel.Phone;
            model.Fax               = amdModel.Fax;
            model.LocalName         = amdModel.Company?.LegalName;
            model.MailingAddress    = amdModel.MailingAddress;
            model.LocalLanguageName = amdModel.LocalLanguageName;
            model.Comment           = amdModel.Comment;
            model.IsDeleted         = (true & amdModel.DeleteDate != null);
            model.ReplacedBy        = amdModel.MergeToId;
            model.City              = amdModel.Address?.City;
            model.Street            = string.Join(" "
                                                  , amdModel.Address?.LocalLanguageAddressPart1
                                                  , amdModel.Address?.LocalLanguageAddressPart2
                                                  , amdModel.Address?.LocalLanguageAddressPart3);
            model.ZipCode = amdModel.Address?.ZipCode;
            model.Name    = amdModel.Company?.ShortName;
            //OData V4 do not allow for deep expand so we have to do it in this way
            AmdService.Model.State state = deepStatesResponse
                                           .Where(x => x.Id == amdModel.Address.StateId)
                                           .FirstOrDefault();
            //======================================
            model.State = state?.Name;

            return(model);
        }
コード例 #2
0
        protected override void LoadAndParseODataClientMethod()
        {
            IQueryable <AmdService.Model.CompanyLocation> response = ExecQuery;

            //OData V4 do not allow for deep expand
            Microsoft.OData.Client.DataServiceQuery <AmdService.Model.State> deepStatesResponse = ODataClientClient.States;
            //=====================================
            if (response == null || deepStatesResponse == null)
            {
                throw new Exception(SynchronizerResource.ErrServiceResponseIsMissing);
            }
            foreach (var line in response)
            {
                CompanyLocationModel parsedModel = MapFromAmdModel(line, deepStatesResponse);

                parsedData.Add(parsedModel.LocationId, parsedModel);
            }
        }