Exemplo n.º 1
0
 private static void Map(NewsArticleInfo from, NewsArticle to, IEnumerable <int> hotNewsIds)
 {
     to.Title         = from.Title;
     to.Url           = from.DesktopUrl;
     to.IsHotContent  = hotNewsIds != null && hotNewsIds.Contains(from.Id);
     to.CommentsCount = from.CommentsCount;
     to.PublishedDate = DateTimeOffset
                        .FromUnixTimeSeconds(from.Published.Timestamp)
                        .UtcDateTime;
     MapSportKind(from, to);
 }
Exemplo n.º 2
0
        private static void MapSportKind(NewsArticleInfo from, NewsArticle to)
        {
            SportKind sportKind = SportKind.Undefined;

            if (from.Section != null)
            {
                string webname = from.Section.WebName;
                sportKind = webname switch
                {
                    "football" => SportKind.Football,
                    "hockey" => SportKind.Hockey,
                    "basketball" => SportKind.Basketball,
                    _ => SportKind.Other,
                };
            }
            to.SportKind = sportKind;
        }