Get data from three level hierarchy - General Discussions - General Discussions - Progress Community
 General Discussions

Get data from three level hierarchy

  • Get data from three level hierarchy
  • Hi

    I need to get three level data. I need to get announce based on login user's classes. Currently, I am using below method but if announcement is shared more than one class, it is showing duplicate. So, could you guide me the correct way of retrieving and how to call this type of method? Sorry, I am a little bit new to asp.net, so, I cannot figure out this method name. Thanks in advanced.

    List<DynamicContent> classCollection = DynamicContentHelper.GetDataByNameSpace(dynamicModuleManager, CPExtranetHelper.UserClassNamespace, ContentLifecycleStatus.Live)
                                                             .FindAll(x => x.GetRelatedItems<DynamicContent>("LoginUser").ToList().Any(y => y.Id == _loginUser));

                    List<DynamicContent> announcementCollection = DynamicContentHelper.GetDataByNameSpace(dynamicModuleManager, CPExtranetHelper.AnnouncementNamespace, ContentLifecycleStatus.Live);
                    
                    foreach (DynamicContent classContent in classCollection)
                   
                        List<DynamicContent> selectedAnnouncement = announcementCollection.FindAll(x => x.GetRelatedItems<DynamicContent>("Class").ToList().Any(y => y.Id == classContent.Id) && x.Status == ContentLifecycleStatus.Live);
                        foreach (DynamicContent announcementContent in selectedAnnouncement)
                       
                            AnnoucementModel _announcementModelItem = new AnnoucementModel();
                            _announcementModelItem.AnnouncementId = announcementContent.Id;
                            _announcementModelItem.AnnouncementTitle = announcementContent.GetValue("Title").ToString();

                            if (announcementContent.GetValue("Date") != null)
                                _announcementModelItem.AnnouncedDate = Convert.ToDateTime(announcementContent.GetValue("Date").ToString()).ToString("dd/MM/yyyy");
                            _announcementModelItem.OrderByDate = Convert.ToDateTime(announcementContent.GetValue("Date").ToString()).ToString();
                            _announcementModelLists.Add(_announcementModelItem);