Ejemplo n.º 1
0
        private CountryModel MapFromAmdModel(AmdService.Model.Country amdModel, IQueryable <AmdService.Model.Region> deepRegionResponse)
        {
            //Country model implementation

            CountryModel model = new CountryModel();

            model.Code = amdModel.Code;
            model.Name = amdModel.Name;
            //OData V4 do not allow for deep expand so we have to do it in this way
            IQueryable <AmdService.Model.Region> region = deepRegionResponse
                                                          .Where(x => x.IsActive)
            ;

            //======================================
            model.RegionCode = (region?.Where(x => x.Code == model.Code).FirstOrDefault())?.ParentCode;
            model.IsDeleted  = (true & amdModel.DeleteDate != null);
            model.ReplacedBy = amdModel.MergeToCode;

            return(model);
        }
Ejemplo n.º 2
0
        protected override void LoadAndParseODataClientMethod()
        {
            //OData Countries do not support Reporting period name
            IQueryable <AmdService.Model.Country> response = ODataClientClient.Countries
                                                             .Where(x => x.IsActive)
                                                             .Where(x => x.IsIso);
            //OData V4 do not allow for deep expand
            IQueryable <AmdService.Model.Region> deepRegionResponse = ODataClientClient.Regions;

            //=====================================
            if (response == null || deepRegionResponse == null)
            {
                throw new Exception(SynchronizerResource.ErrServiceResponseIsMissing);
            }
            foreach (var line in response)
            {
                CountryModel parsedModel = MapFromAmdModel(line, deepRegionResponse);
                if (parsedModel.IsValid)
                {
                    parsedData.Add(parsedModel.Code, parsedModel);
                }
            }
        }