public List<MetroContract_Shout> GetAniDBRecommendationsForAnime(int animeID, int maxRecords) { List<MetroContract_Shout> contracts = new List<MetroContract_Shout>(); try { using (var session = JMMService.SessionFactory.OpenSession()) { AniDB_RecommendationRepository repBA = new AniDB_RecommendationRepository(); int cnt = 0; foreach (AniDB_Recommendation rec in repBA.GetByAnimeID(session, animeID)) { MetroContract_Shout shout = new MetroContract_Shout(); shout.UserID = rec.UserID; shout.UserName = ""; // shout details shout.ShoutText = rec.RecommendationText; shout.IsSpoiler = false; shout.ShoutDate = null; shout.ImageURL = string.Empty; AniDBRecommendationType recType = (AniDBRecommendationType)rec.RecommendationType; switch (recType) { case AniDBRecommendationType.ForFans: shout.ShoutType = (int)WhatPeopleAreSayingType.AniDBForFans; break; case AniDBRecommendationType.MustSee: shout.ShoutType = (int)WhatPeopleAreSayingType.AniDBMustSee; break; case AniDBRecommendationType.Recommended: shout.ShoutType = (int)WhatPeopleAreSayingType.AniDBRecommendation; break; } shout.Source = "AniDB"; cnt++; contracts.Add(shout); if (cnt == maxRecords) break; } return contracts; } } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); return contracts; } }
public List<MetroContract_Shout> GetTraktShoutsForAnime(int animeID, int maxRecords) { List<MetroContract_Shout> shouts = new List<MetroContract_Shout>(); try { using (var session = JMMService.SessionFactory.OpenSession()) { Trakt_FriendRepository repFriends = new Trakt_FriendRepository(); List<TraktTV_ShoutGet> shoutsTemp = TraktTVHelper.GetShowShouts(session, animeID); if (shoutsTemp == null || shoutsTemp.Count == 0) return shouts; int cnt = 0; foreach (TraktTV_ShoutGet sht in shoutsTemp) { MetroContract_Shout shout = new MetroContract_Shout(); Trakt_Friend traktFriend = repFriends.GetByUsername(session, sht.user.username); // user details Contract_Trakt_User user = new Contract_Trakt_User(); if (traktFriend == null) shout.UserID = 0; else shout.UserID = traktFriend.Trakt_FriendID; shout.UserName = sht.user.username; // shout details shout.ShoutText = sht.shout; shout.IsSpoiler = sht.spoiler; shout.ShoutDate = Utils.GetAniDBDateAsDate(sht.inserted); shout.ImageURL = sht.user.avatar; shout.ShoutType = (int)WhatPeopleAreSayingType.TraktShout; shout.Source = "Trakt"; cnt++; shouts.Add(shout); if (cnt == maxRecords) break; } if (shouts.Count > 0) { List<SortPropOrFieldAndDirection> sortCriteria = new List<SortPropOrFieldAndDirection>(); sortCriteria.Add(new SortPropOrFieldAndDirection("ShoutDate", false, SortType.eDateTime)); shouts = Sorting.MultiSort<MetroContract_Shout>(shouts, sortCriteria); } } } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } return shouts; }