Esempio n. 1
0
        public RedirectResult Random()
        {
            RedirectResult result;

            try
            {
                this.EntityContext.TryAttach(this.ActiveUser);

                Data.Comic comic = this.EntityContext.TryGetRandomComic(this.ActiveUser, this.Friends);
                if (comic == null || (comic.IsPrivate && !this.IsFriendOrSelf(comic.Author)))
                {
                    throw new Exception("Unable to find the requested comic.");
                }
                result = this.Redirect(ComicUrlHelper.GetReadUrl(comic));
            }
            finally
            {
                this.EntityContext.TryDetach(this.ActiveUser);
            }
            return(result);
        }
Esempio n. 2
0
        protected void Init(Data.Comic source, ComicStat.ComicStatPeriod statsPeriod)
        {
            this.ComicId     = source.ComicId;
            this.Uid         = source.Uid;
            this.TemplateId  = source.TemplateId;
            this.CreateTime  = source.CreateTime;
            this.UpdateTime  = source.UpdateTime;
            this.PublishTime = source.PublishTime;
            this.FeatureTime = source.FeatureTime;
            this.IsPublished = source.IsPublished;
            this.Title       = source.Title;
            this.Description = source.Description;
            this.ShareText   = source.ShareText;
            this.IsPrivate   = source.IsPrivate;

            this.ReadUrl       = ComicUrlHelper.GetReadUrl(source);
            this.ComicUrl      = ComicUrlHelper.GetRenderUrl(source, RenderMode.Comic);
            this.ThumbUrl      = ComicUrlHelper.GetRenderUrl(source, RenderMode.Thumb);
            this.FrameUrl      = ComicUrlHelper.GetRenderUrl(source, RenderMode.Frame);
            this.FrameThumbUrl = ComicUrlHelper.GetRenderUrl(source, RenderMode.FrameThumb);
            this.RemixUrl      = ComicUrlHelper.GetRemixUrl(source);

            this.Author   = new ClientUser(source.Author);
            this.Stats    = new ClientComicStat(source.PeriodStats(statsPeriod));
            this.Template = new ClientTemplate(source.Template);

            if (source.ComicTextBubbles.IsLoaded)
            {
                this.Bubbles = source.ComicTextBubbles.ToList().Select(b => new ClientComicTextBubble(b)).ToList();
            }
            if (source.ComicPhotos.IsLoaded)
            {
                this.Photos = source.ComicPhotos
                              .OrderBy(p => p.TemplateItem.Ordinal)
                              .ToList()
                              .Select(p => new ClientPhoto(p.Photo))
                              .ToList();
            }
        }