public static ProfileHistoryItemViewModel Initialize(this ProfileHistoryItemViewModel model, ProfileHistoryItem historyItem, ITimestampFormatter timestampFormatter)
        {
            model.Text      = historyItem.Text;
            model.Timestamp = timestampFormatter.Format(historyItem.Timestamp);

            if (historyItem.Anime != null)
            {
                model.TitleInfo = new TitlePreviewPartialViewModel
                {
                    ControllerName = "Anime",
                    Title          = new TitlePreviewViewModel().Initialize(historyItem.Anime)
                }
            }
            ;
            if (historyItem.Manga != null)
            {
                model.TitleInfo = new TitlePreviewPartialViewModel
                {
                    ControllerName = "Manga",
                    Title          = new TitlePreviewViewModel().Initialize(historyItem.Manga)
                }
            }
            ;
            if (historyItem.UserList != null)
            {
                model.UserList = new UserListInfoViewModel().Initialize(historyItem.UserList);
            }

            return(model);
        }
    }
}
Esempio n. 2
0
        public static CommentViewModel Initialize(this CommentViewModel model, Comment comment, ITimestampFormatter timestampFormatter)
        {
            model.AvatarSrc = comment.Profile.Avatar?.Id.ToString() ?? "/images/missing-square.jpg";
            model.Login     = comment.Profile.Login;
            model.Text      = comment.Text;
            model.Timestamp = timestampFormatter.Format(comment.Timestamp);

            return(model);
        }
Esempio n. 3
0
        public static OneUpdateViewModel Initialize(this OneUpdateViewModel model, Update update, ITagTranslator tagTranslator, ITimestampFormatter timestampFormatter)
        {
            model.Title     = update.Anime.Title;
            model.TitleKey  = update.Anime.Key;
            model.Tag       = tagTranslator.ToTag(update.Tag);
            model.TagInfo   = update.Tag;
            model.Timestamp = timestampFormatter.Format(update.Timestamp);
            model.ImageSrc  = update.Anime.ImageSrc;
            model.Info      = new List <DataListInformationViewModel>().Initialize(update.Infomation);

            return(model);
        }
        public static OneNewsViewModel Initialize(this OneNewsViewModel model, News news, ITagTranslator tagTranslator, ITimestampFormatter timestampFormatter)
        {
            model.Key       = news.Id;
            model.Title     = news.Title;
            model.Tag       = tagTranslator.ToTag(news.Tag);
            model.TagInfo   = news.Tag;
            model.Timestamp = timestampFormatter.Format(news.Timestamp);
            model.ImageSrc  = news.ImageSrc;
            model.Text      = news.Text;

            return(model);
        }
Esempio n. 5
0
        public void InMinute()
        {
            var date = DateTime.Now.AddSeconds(-10);

            Assert.Equal("Только что", formatter.Format(date));
        }