Example #1
0
        public static DateTime PeriodToCutoff(ComicStat.ComicStatPeriod period)
        {
            DateTime cutoff;

            switch (period)
            {
            case ComicStat.ComicStatPeriod.AllTime:
                cutoff = new DateTime(2011, 1, 1);
                break;

            case ComicStat.ComicStatPeriod.Year:
                cutoff = new DateTime(DateTime.Now.Year, 1, 1);
                break;

            case ComicStat.ComicStatPeriod.Month:
            default:
                cutoff = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                break;

            case ComicStat.ComicStatPeriod.Week:
                cutoff = DateTime.Now.Date.AddDays((int)DateTime.Now.DayOfWeek * -1);
                break;

            case ComicStat.ComicStatPeriod.Day:
                cutoff = DateTime.Now.Date;
                break;
            }
            return(cutoff);
        }
Example #2
0
 public ViewDirectory(List <Data.Comic> comics, DirectoryMode mode, ComicStat.ComicStatPeriod period, int page, int maxPage)
 {
     this.Comics  = comics.Select(c => new ClientComic(c)).ToList();
     this.Mode    = mode;
     this.Period  = period;
     this.Page    = page;
     this.MaxPage = maxPage;
 }
Example #3
0
        public ComicStat PeriodStats(ComicStat.ComicStatPeriod period)
        {
            ComicStat stat = this.ComicStat.FirstOrDefault(s => s.Period == (int)period);

            if (stat == null)
            {
                stat = new ComicStat()
                {
                    ComicId = this.ComicId,
                    Period  = (int)period
                };
            }
            return(stat);
        }
Example #4
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();
            }
        }
Example #5
0
 public ClientComic(Data.Comic source, ComicStat.ComicStatPeriod statsPeriod)
 {
     this.Init(source, statsPeriod);
 }
        public IQueryable <Comic> SearchPublishedComics(string search, User reader, List <long> friends, ComicStat.ComicStatPeriod period, string language)
        {
            DateTime cutoff = Data.ComicStat.PeriodToCutoff(period);

            return(this.Comics
                   .Where(c => c.IsPublished && c.PublishTime.Value >= cutoff && (c.Title.Contains(search) || c.Description.Contains(search)))
                   .FilterComicVisibility(reader, friends)
                   .FilterComicLanguage(language));
        }
        public IQueryable <Comic> ListPublishedComics(User author, User reader, bool isFriend, ComicStat.ComicStatPeriod period, string language)
        {
            DateTime cutoff = Data.ComicStat.PeriodToCutoff(period);

            return(this.Comics
                   .Where(c => c.Uid == author.Uid && c.IsPublished && c.PublishTime.Value >= cutoff)
                   .FilterComicVisibility(reader, isFriend)
                   .FilterComicLanguage(language));
        }
        public IQueryable <Comic> ListPublishedComics(User reader, List <long> friends, ComicStat.ComicStatPeriod period, string language)
        {
            DateTime cutoff = Data.ComicStat.PeriodToCutoff(period);

            return(this.Comics
                   .Where(c => c.IsPublished && c.PublishTime.Value >= cutoff)
                   .FilterComicVisibility(reader, friends)
                   .FilterComicLanguage(language));
        }