public ActionResult RenderFeatureTopRecent(UserFeatureTopViewModel model)
        {
            model.TopListView = GetTopRecentFeatures(model);

            //check the role of the user.

            //if the user is  SHIP administrators and SHIP director then only count the pending
            //for other role set it to zero so that the yellow round pending button wont show.


            if (System.Web.HttpContext.Current.User.IsInRole("shipdirector") ||
                System.Web.HttpContext.Current.User.IsInRole("shipadmin"))
            {
                int pusers    = CountPendingUsers();
                int presouces = CountPendingResources();
                model.PendingCount = pusers + presouces;
            }
            else
            {
                model.PendingCount = 0;
            }

            return(PartialView("feature", model));
        }
        private List <SResult> GetTopRecentFeatures(UserFeatureTopViewModel model)
        {
            int featureRootId = 0;

            List <SResult> features = new List <SResult>();

            featureRootId = UmbracoShipTac.Code.ConfigUtil.FeatureRootId;

            string[] roles = System.Web.Security.Roles.GetRolesForUser(User.Identity.Name);
            //  filter = filter.And().Field("roles", roles[0]);


            //IEnumerable<Umbraco.Core.Models.IContent> items;
            //items = Services.ContentService.GetDescendants(featureRootId).Where(x => x.ContentType.Alias == "UserFeature"
            //    && x.GetValue("roles").ToString().Contains(roles[0]))
            //    .OrderByDescending(x => x.CreateDate).Take(8);


            //sort by updatedate rather than created date..
            IEnumerable <Umbraco.Core.Models.IContent> items;

            items = Services.ContentService.GetDescendants(featureRootId).Where(x => x.ContentType.Alias == "UserFeature" &&
                                                                                myfunc(x.GetValue("role").ToString())
                                                                                .Contains(roles[0]))
                    .OrderByDescending(x => x.UpdateDate).Take(8);



            //items = Services.ContentService.GetDescendants(featureRootId);



            //if (CurrentPage.HasValue("featureImage")){
            //var dynamicMediaItem = Umbraco.Media(CurrentPage.featureImage);
            //<img src="@dynamicMediaItem.umbracoFile" alt="@dynamicMediaItem.Name"/>

            dynamic dynamicMediaItem;
            string  imgurl = null;

            foreach (var aItem in items)
            {
                if (aItem.GetValue("featureimage") != null)
                {
                    dynamicMediaItem = Umbraco.Media(aItem.GetValue("featureimage"));
                    imgurl           = dynamicMediaItem.umbracoFile;
                }
                else
                {
                    imgurl = "";
                }



                SResult result = new SResult()
                {
                    Id       = aItem.Id.ToString(),
                    Url      = umbraco.library.NiceUrl(Convert.ToInt32(aItem.Id.ToString())),
                    NodeName = aItem.GetValue("featureheader").ToString(), //aItem.Name, FeatureHeader
                    // Text = "Test this one"
                    Text     = System.Text.RegularExpressions.Regex.Replace(aItem.GetValue("featurecontent").ToString(), "<.*?>", String.Empty),
                    ImageUrl = imgurl
                };

                //do the difference of nodename count
                int charToTake = 200 - result.NodeName.Length;

                result.Text = result.Text.Substring(0, Math.Min(result.Text.Length, charToTake));

                features.Add(result);
            }


            return(features);
        }