示例#1
0
 public static async Task<TopicSection> FromModelAsync(ApplicationDbContext context, TopicModel topicModel)
 {
     TopicSection section = new TopicSection();
     section.TopicTitle = topicModel.TopicTitle;
     section.TopicId = topicModel.TopicId;
     section.TopicDescription = topicModel.Description;
     ArticleModel[] newArticles =
         context.Articles.Where(f => !f.IsDraft && f.ThemeId.Equals(topicModel.TopicId))
             .OrderBy(f => f.CreationTime)
             .Take(3)
             .ToArray();
     section.NewModels = newArticles;
     List<ArticleModel> flamedArticles = new List<ArticleModel>();
     var flamedArticlesQuery = context.CurrentRanking.Where(f => f.TopicId.Equals(topicModel.TopicId))
         .OrderBy(f => f.PVCoefficient).Take(3).ToList();
     foreach (var currentRankingModel in flamedArticlesQuery)
     {
         flamedArticles.Add(await context.Articles.FindAsync(currentRankingModel.ArticleId));
     }
     section.FlamedModels = flamedArticles.ToArray();
     return section;
 }
示例#2
0
 public static TopicModel GenerateNewTopic()
 {
     TopicModel model=new TopicModel();
     model.TopicId = IdGenerator.getId(10);
     return model;
 }