public MasterDataEnvelope BuildSalesmanRoute(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
        {
            var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
            if (_salesmanRouteRepository.GetItemUpdatedSinceDateTime(dateSince))
            {
                var sroutes = new List<SalesmanRoute>();
                if (cct != null)
                    switch (cct.CostCentreType)
                    {
                        case CostCentreType.Distributor:
                            sroutes =  _salesmanRouteRepository.GetItemUpdated(dateSince)
                                .Where(n => n.Route.Region.Id == ((Distributor) cct).Region.Id).ToList();
                            break;
                        case CostCentreType.DistributorSalesman:
                            sroutes =  _salesmanRouteRepository.GetItemUpdated(dateSince)
                                .Where(n => n.DistributorSalesmanRef.Id == cct.Id).ToList();
                            break;
                        case CostCentreType.PurchasingClerk:
                            sroutes = _salesmanRouteRepository.GetItemUpdated(dateSince)
                                .Where(n => n.DistributorSalesmanRef.Id == cct.Id).ToList();
                            break;
                    }

                envelope.masterData = sroutes.Select(n => n as MasterEntity).ToList();
            }
            return envelope;
        }
 public MasterDataEnvelope BuildAssetStatus(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_assetStatusRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         envelope.masterData = _assetStatusRepository.GetItemUpdated(dateSince).Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
        public MasterDataEnvelope BuildTarget(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
        {
            var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
            if (_targetRepository.GetItemUpdatedSinceDateTime(dateSince))
            {
                var targets = new List<Target>();
                if (cct != null)
                    switch (cct.CostCentreType)
                    {
                        case CostCentreType.Distributor:
                        case CostCentreType.Hub:
                            var costCentreIds = _costCentreRepository.GetAll(true)
                                .Where(n => n.ParentCostCentre != null && n.ParentCostCentre.Id == cct.Id)
                                .Select(n => n.Id)
                                .ToList();
                            targets = _targetRepository.GetItemUpdated(dateSince)
                                .Where(n => n.CostCentre.Id == cct.Id || costCentreIds.Contains(n.CostCentre.Id))
                                .ToList();
                            break;
                        case CostCentreType.DistributorSalesman:
                            var dist = _costCentreRepository.GetById(cct.ParentCostCentre.Id) as Distributor;
                            var distCCIds = _costCentreRepository.GetAll(true)
                                .Where(n => n.ParentCostCentre != null && n.ParentCostCentre.Id == dist.Id)
                                .Select(n => n.Id).ToList();
                            targets = _targetRepository.GetItemUpdated(dateSince)
                               .Where(n => distCCIds.Contains(n.CostCentre.Id) || cct.Id == n.CostCentre.Id)
                               .ToList();
                            break;
                    }

                envelope.masterData = targets.Select(n => n as MasterEntity).ToList();
            }
            return envelope;
        }
 public MasterDataEnvelope BuildProductGroupDiscount(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_productDiscountGroupRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         envelope.masterData = _productDiscountGroupRepository.GetItemUpdated(dateSince).Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
 public MasterDataEnvelope BuildCentre(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_centreRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         var centres = new List<Centre>();
         var hubRoutes = new List<Route>();
         List<MasterDataAllocation> hubRouteAllocations = new List<MasterDataAllocation>();
         List<Guid> centreIds_allocated_to_hubRoutes = new List<Guid>();
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Hub:
                     centres = _centreRepository.GetAll(true).Where(r => r.Hub.Id == cct.Id).ToList();
                     break;
                 case CostCentreType.PurchasingClerk:
                     centres = _centreRepository.GetAll(true).ToList();
                     break;
             }
         envelope.masterData = centres.Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
 public MasterDataEnvelope BuildDistributorSalesman(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_distributorSalesmanRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         List<DistributorSalesman> ds = _distributorSalesmanRepository.GetItemUpdated(dateSince)
             .OfType<DistributorSalesman>().ToList();
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Distributor:
                     ds = ds.Where(n => n.ParentCostCentre.Id == cct.Id).ToList();
                     break;
                 case CostCentreType.DistributorSalesman:
                     ds = ds.Where(n => n.ParentCostCentre.Id == cct.ParentCostCentre.Id).ToList();
                     break;
             }
         envelope.masterData = ds.Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
 public MasterDataEnvelope BuildContact(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_contactRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         var contacts = new List<Contact>();
         var ccIds = new List<Guid>();
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Distributor:
                 case CostCentreType.Hub:
                     var relevantCostCentreIds = _costCentreRepository.GetAll(true)
                         .Where(c => (c.ParentCostCentre != null && c.ParentCostCentre.Id == cct.Id) || c.Id == cct.Id)
                         .Select(c => c.Id);
                     var relevantdUserIds =
                         _userRepository.GetAll(true).Where(u => relevantCostCentreIds.Contains(u.CostCentre)).Select(u => u.Id);
                     var requiredContactOwnerIds = relevantCostCentreIds.Union(relevantdUserIds).ToList();
                     contacts = _contactRepository.GetItemUpdated(dateSince)
                         .Where(n => requiredContactOwnerIds.Contains(n.ContactOwnerMasterId))
                         .ToList();
                     break;
                 case CostCentreType.DistributorSalesman:
                     var distId = _costCentreRepository.GetById(cct.Id).ParentCostCentre.Id;
                     ccIds = _costCentreRepository.GetAll(true)
                         .Where(n => (n.ParentCostCentre != null && n.ParentCostCentre.Id == distId)
                             || n.Id == distId || n.Id == cct.Id)
                         .Select(n => n.Id).ToList();
                     contacts = _contactRepository.GetItemUpdated(dateSince)
                         .Where(n => ccIds.Contains(n.ContactOwnerMasterId))
                         .ToList();
                     break;
                 case CostCentreType.PurchasingClerk:
                     var hubId = _costCentreRepository.GetById(cct.Id).ParentCostCentre.Id;
                     ccIds = _costCentreRepository.GetAll(true)
                         .Where(n => (n.ParentCostCentre != null && n.ParentCostCentre.Id == hubId)
                             || n.Id == hubId || n.Id == cct.Id)
                         .Select(n => n.Id).ToList();
                     contacts = _contactRepository.GetItemUpdated(dateSince)
                         .Where(n => ccIds.Contains(n.ContactOwnerMasterId))
                         .ToList();
                     break;
             }
         envelope.masterData = contacts.Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
        public ResponseMasterDataInfo GetPayments(Guid costCentreApplicationId)
        {
            MasterDataInfo mdi = new MasterDataInfo { EntityName = "Payment" };
            // int entityId = (int)mdc;

            MasterDataEnvelope envelope = null;

            envelope = _clientMasterDataTrackerRepository.GetPayments(costCentreApplicationId);

            List<MasterBaseDTO> masterBaseDTOList = new List<MasterBaseDTO>();
            if (envelope == null)
            {
                envelope = new MasterDataEnvelope()
                {
                    masterData = new List<MasterEntity>(),
                    masterDataName = ""
                };
            }

            foreach (MasterEntity entity in envelope.masterData)
            {
                MasterBaseDTO masterBaseDTO = masterDataToDTOMapping.Map(entity as PaymentTracker);
                if (masterBaseDTO == null)
                    continue;
                masterBaseDTOList.Add(masterBaseDTO);

            }

            mdi.MasterDataItems = masterBaseDTOList.ToArray();

            return new ResponseMasterDataInfo()
            {
                ErrorInfo = "Success",
                MasterData = mdi
            };
        }
 public MasterDataEnvelope BuildOutlet(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     bool isAssignedoutlet = _salesmanRouteRepository.GetItemUpdatedSinceDateTime(dateSince);
     if (_outletRepository.GetItemUpdatedSinceDateTime(dateSince) || isAssignedoutlet)
     {
         List<Outlet> itier = _outletRepository.GetItemUpdated(dateSince).OfType<Outlet>().ToList();
         if (cct != null)
         {
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Distributor:
                 case CostCentreType.Hub:
                     itier = itier.Where(o => o.ParentCostCentre.Id == cct.Id).ToList();//cn: above code filters n returns outlets for routes assigned to salesmen only. For routes not assigned to salesmen their outltets r not returned.
                     break;
                 case CostCentreType.DistributorSalesman:
                     {
                         var salesmanroutes = _salesmanRouteRepository.GetAll(true).ToList();
                         salesmanroutes = salesmanroutes.Where(n => n.DistributorSalesmanRef.Id == cct.Id).ToList();
                         itier = itier.Where(n => salesmanroutes.Select(r => r.Route.Id).Contains(n.Route.Id)).ToList();
                         if (isAssignedoutlet)
                         {
                             var routeIds = _salesmanRouteRepository.GetItemUpdated(dateSince)
                                 .Where(s => s.DistributorSalesmanRef.Id == cct.Id)
                                 .Select(n => n.Route.Id);
                             var outlets = _outletRepository.GetAll(true).OfType<Outlet>().Where(o => routeIds.Contains(o.Id))
                              .ToList();
                             itier = itier.Union(outlets).Distinct().ToList();
                         }
                         break;
                     }
             }
         }
         envelope.masterData = itier.Select(n => n as MasterEntity).ToList();// _outletRepository.GetAll().Select(n => n as MasterEntity).ToList()
     }
     return envelope;
 }
 public MasterDataEnvelope BuildDistributorPendingDispatchWarehouse(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_distributorPendingDispatchWarehouseRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         var entity = _distributorPendingDispatchWarehouseRepository.GetItemUpdated(dateSince);
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Distributor:
                 case CostCentreType.Hub:
                     entity = entity.Where(n => n.ParentCostCentre.Id == cct.Id);
                     break;
                 case CostCentreType.DistributorSalesman:
                     entity = entity.Where(n => n.ParentCostCentre.Id == cct.ParentCostCentre.Id);
                     break;
             }
         envelope.masterData = entity.Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
 public MasterDataEnvelope BuildRouteRegionAllocation(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_masterDataAllocatioRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         if (cct != null)
         {
             envelope.masterData = _masterDataAllocatioRepository
                 .GetItemUpdated(dateSince)
                 .Where(x => x.AllocationType == MasterDataAllocationType.RouteRegionAllocation)
                 .Select(n => n as MasterEntity)
                 .ToList();
         }
     }
     return envelope;
 }
 public MasterDataEnvelope BuildVehicle(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_vehicleRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Hub:
                     envelope.masterData = _vehicleRepository.GetItemUpdated(dateSince)
                         .Select(n => n as MasterEntity)
                         .ToList();
                     break;
                 case CostCentreType.PurchasingClerk:
                     envelope.masterData = _vehicleRepository.GetItemUpdated(dateSince)
                         .Select(n => n as MasterEntity)
                         .ToList();
                     break;
             }
     }
     return envelope;
 }
 public MasterDataEnvelope BuildFieldClerk(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_purchasingClerkRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         var costCentreIds = _costCentreRepository.GetAll(true)
             .Where(n => n.ParentCostCentre != null && n.ParentCostCentre.Id == cct.Id)
             .Distinct().Select(n => n.Id).ToList();
         var userIds = new List<Guid>();
         var clerks = new List<PurchasingClerk>();
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Hub:
                     userIds = _userRepository.GetAll(true)
                         .Where(n => n.CostCentre == cct.Id || costCentreIds.Contains(n.CostCentre))
                         .Select(n => n.Id)
                         .ToList();
                     clerks = _purchasingClerkRepository
                         .GetItemUpdated(dateSince)
                         .Cast<PurchasingClerk>()
                         .Where(n => n.User != null && userIds.Contains(n.User.Id))
                         .ToList();
                     break;
                 case CostCentreType.PurchasingClerk:
                     userIds = _userRepository.GetAll(true)
                         .Where(n => n.CostCentre == cct.Id || costCentreIds.Contains(n.CostCentre))
                         .Select(n => n.Id)
                         .ToList();
                     clerks = _purchasingClerkRepository
                         .GetItemUpdated(dateSince)
                         .Cast<PurchasingClerk>()
                         .Where(n => n.User != null && userIds.Contains(n.User.Id))
                         .ToList();
                     break;
             }
         envelope.masterData = clerks.Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
 public MasterDataEnvelope BuildOutletPriority(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_outletPriorityRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         List<OutletPriority> outletPriorityList = new List<OutletPriority>();
         List<Route> routes = new List<Route>();
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Distributor:
                     routes = _routeRepository.GetAll(true).Where(p => p.Region.Id == cct.Id).ToList();
                     outletPriorityList = _outletPriorityRepository.GetItemUpdated(dateSince).Where(n => routes.Select(p => p.Id).Contains(n.Route.Id)).ToList();
                     break;
                 case CostCentreType.DistributorSalesman:
                     routes = _routeRepository.GetAll(true).Where(o => _salesmanRouteRepository
                                                                                 .GetAll()
                                                                                 .Where(s => s.DistributorSalesmanRef.Id == cct.Id)
                                                                                 .Select(n => n.Route.Id)
                                                                                 .Contains(o.Id))
                          .ToList();
                     outletPriorityList = _outletPriorityRepository.GetItemUpdated(dateSince).Where(n => routes.Select(p => p.Id).Contains(n.Route.Id)).ToList();
                     break;
             }
         envelope.masterData = outletPriorityList.Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
        public MasterDataEnvelope BuildRoute(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
        {
            var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
            bool hasSalesmanRoutes = _salesmanRouteRepository.GetItemUpdatedSinceDateTime(dateSince);
            bool hasPurchasingClerkRoutes = false;
            bool isPurchasingClerk = cct is PurchasingClerk;
            if (isPurchasingClerk)
            {
                hasPurchasingClerkRoutes = ((PurchasingClerk) cct).PurchasingClerkRoutes.Any();
            }
            if ( _routeRepository.GetItemUpdatedSinceDateTime(dateSince) || hasSalesmanRoutes || hasPurchasingClerkRoutes)
            {
                List<Route> routes = _routeRepository.GetItemUpdated(dateSince).ToList();
                if (cct != null)
                    switch (cct.CostCentreType)
                    {
                        case CostCentreType.Distributor:
                            routes = routes.Where(n => n.Region.Id == ((Distributor)cct).Region.Id).ToList();
                            break;
                        case CostCentreType.Hub:
                            routes = routes.Where(n => n.Region.Id == ((Hub)cct).Region.Id).ToList();
                            break;
                        case CostCentreType.DistributorSalesman:
                            routes = routes.Where(o => _salesmanRouteRepository.GetAll()
                                                         .Where(s => s.DistributorSalesmanRef.Id == cct.Id)
                                                         .Select(n => n.Route.Id)
                                                         .Contains(o.Id))
                                .ToList();
                            if (hasSalesmanRoutes)
                            {
                                var routeIds = _salesmanRouteRepository.GetItemUpdated(dateSince)
                                    .Where(s => s.DistributorSalesmanRef.Id == cct.Id)
                                    .Select(n => n.Route.Id);
                                var route = _routeRepository.GetAll(true).Where(o => routeIds.Contains(o.Id)).ToList();
                                routes = routes.Union(route).Distinct().ToList();
                            }
                            break;
                        case CostCentreType.PurchasingClerk:
                            routes = routes.Where(r => 
                                _purchasingClerkRouteRepository.GetAll()
                                .Where(pcr => pcr.PurchasingClerkRef.Id == cct.Id)
                                .Select(n => n.Route.Id)
                                .Contains(r.Id))
                                .ToList();
                            if (hasPurchasingClerkRoutes)
                            {
                                var routeIds = ((PurchasingClerk) cct).PurchasingClerkRoutes.Select(n => n.Route.Id).ToList();
                                routes = _routeRepository.GetAll(true).Where(r => routeIds.Contains(r.Id)).ToList();
                            }
                            break; 
                    }

                envelope.masterData = routes.Select(n => n as MasterEntity).ToList();
            }
            return envelope;
        }
 public MasterDataEnvelope BuildOutletVisitDay(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_outletVisitDayRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         List<OutletVisitDay> outletdaysList = new List<OutletVisitDay>();
         List<Outlet> outlet = new List<Outlet>();
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Distributor:
                     outlet = _costCentreRepository.GetAll(false).OfType<Outlet>().Where(p => p.ParentCostCentre.Id == cct.Id).ToList();
                     outletdaysList = _outletVisitDayRepository.GetItemUpdated(dateSince).Where(n => outlet.Select(p => p.Id).Contains(n.Outlet.Id)).ToList();
                     break;
                 case CostCentreType.DistributorSalesman:
                     var salesmanroutes = _salesmanRouteRepository.GetAll(true).ToList();
                     salesmanroutes = salesmanroutes.Where(n => n.DistributorSalesmanRef.Id == cct.Id).ToList();
                     outlet = _outletRepository.GetAll().OfType<Outlet>().Where(n => salesmanroutes.Select(r => r.Route.Id).Contains(n.Route.Id)).ToList();
                     outletdaysList = _outletVisitDayRepository.GetItemUpdated(dateSince).Where(n => outlet.Select(p => p.Id).Contains(n.Outlet.Id)).ToList();
                     break;
             }
         envelope.masterData = outletdaysList.Select(n => n as MasterEntity).ToList();
     }
     return envelope;
 }
 public MasterDataEnvelope BuildUser(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     List<User> users = _userRepository.GetItemUpdated(dateSince).ToList();
     if (cct != null)
         switch (cct.CostCentreType)
         {
             case CostCentreType.Distributor:
             case CostCentreType.Hub:
                 {
                     var costcentreid = _costCentreRepository.GetAll(true)
                         .Where(n => n.ParentCostCentre != null)
                         .Where(n => n.ParentCostCentre.Id == cct.Id)
                         .Select(x => x.Id)
                         .ToList();
                     users = users.Where(n => n.CostCentre == cct.Id || costcentreid.Contains(n.CostCentre)).ToList();
                 }
                 break;
             case CostCentreType.DistributorSalesman:
                 users = users.Where(n => n.CostCentre == cct.Id).ToList();
                 break;
         }
     envelope.masterData = users.Select(n => n as MasterEntity).ToList();
     return envelope;
 }
        public ResponseMasterDataInfo GetTableContents(Guid costCentreApplicationId, string entityName)
        {
            MasterDataCollective mdc = (MasterDataCollective)Enum.Parse(typeof(MasterDataCollective), entityName, true);

            MasterDataInfo mdi = new MasterDataInfo { EntityName = entityName };
            int entityId = (int)mdc;

            MasterDataEnvelope envelope = null;

            envelope = _clientMasterDataTrackerRepository.GetTableContents(costCentreApplicationId, entityId);

            List<MasterBaseDTO> masterBaseDTOList = new List<MasterBaseDTO>();
            if (envelope == null)
            {
                envelope = new MasterDataEnvelope()
                {
                    masterData = new List<MasterEntity>(),
                    masterDataName = ""
                };
            }

            foreach (MasterEntity entity in envelope.masterData)
            {
                MasterBaseDTO masterBaseDTO = MapResolver(mdc, entity);
                if (masterBaseDTO == null)
                    continue;
                masterBaseDTOList.Add(masterBaseDTO);

            }

            mdi.MasterDataItems = masterBaseDTOList.ToArray();

            return new ResponseMasterDataInfo()
            {
                ErrorInfo = "Success",
                MasterData = mdi
            };
        }
 public MasterDataEnvelope BuildCommodityOwner(DateTime dateSince, MasterDataCollective masterdata, CostCentre cct)
 {
     var envelope = new MasterDataEnvelope() { masterDataName = masterdata.ToString() };
     if (_commodityOwnerRepository.GetItemUpdatedSinceDateTime(dateSince))
     {
         var supplierIds = new List<Guid>();
         if (cct != null)
             switch (cct.CostCentreType)
             {
                 case CostCentreType.Hub:
                     supplierIds = _commoditySupplierRepository.GetAll(true)
                         .Where(n => n.ParentCostCentre.Id == cct.Id)
                         .Select(n => n.Id).ToList();
                     envelope.masterData = _commodityOwnerRepository.GetItemUpdated(dateSince)
                             .Where(n => supplierIds.Contains(n.CommoditySupplier.Id))
                             .Select(n => n as MasterEntity).ToList();
                     break;
                 case CostCentreType.PurchasingClerk:
                     var hub = _costCentreRepository.GetById(cct.ParentCostCentre.Id) as Hub;
                     supplierIds = _commoditySupplierRepository.GetAll(true)
                         .Where(n => n.ParentCostCentre.Id == hub.Id)
                         .Select(n => n.Id).ToList();
                     envelope.masterData = _commodityOwnerRepository.GetItemUpdated(dateSince)
                             .Where(n =>  supplierIds.Contains(n.CommoditySupplier.Id))
                             .Select(n => n as MasterEntity).ToList();
                     break;
             }
     }
     return envelope;
 }