Chronozoom.UI.ChronozoomSVC.GetUserFavorites C# (CSharp) Method

GetUserFavorites() public method

public GetUserFavorites ( ) : Collection
return Collection
        public Collection<TimelineShortcut> GetUserFavorites()
        {
            return ApiOperation<Collection<TimelineShortcut>>(delegate(User user, Storage storage)
            {
            #if RELEASE
                if (user == null)
                {
                    return null;
                }
            #endif

                Guid userId = user == null || user.Id == null ? Guid.Empty : user.Id;
                var cacheKey = string.Format(CultureInfo.InvariantCulture, "UserFavorites - {0}", userId);
                if (Cache.Contains(cacheKey))
                {
                    return (Collection<TimelineShortcut>)Cache.Get(cacheKey);
                }

                var triple = storage.GetTriplet(String.Format("czusr:{0}", user != null ? user.Id : Guid.Empty), "czpred:favorite").FirstOrDefault();
                if (triple == null)
                    return null;

                var elements = new Collection<TimelineShortcut>();
                foreach (var t in triple.Objects)
                {
                    var objName = TripleName.Parse(t.Object);
                    if (objName.Prefix == "cztimeline")
                    {
                        var g = new Guid(objName.Name);
                        var timeline = storage.Timelines.Where(x => x.Id == g)
                            .Include("Collection")
                            .Include("Collection.User")
                            .Include("Collection.SuperCollection")
                            .Include("Exhibits")
                            .Include("Exhibits.ContentItems")
                            .FirstOrDefault();

                        if (timeline != null)
                            elements.Add(storage.GetTimelineShortcut(timeline));
                    }
                }

                Cache.Add(cacheKey, elements);

                return elements;
            });
        }