More in this section

Forums / General Discussions / Get data from three level hierarchy

Get data from three level hierarchy

1 posts, 0 answered
  1. Khaing Su Hlaing -
    Khaing Su Hlaing - avatar
    1 posts
    15 Dec 2015
    21 Dec 2015
    Link to this post


    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, 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();

1 posts, 0 answered