/// <summary> /// Creates an <see cref="SVR_AnimeGroup"/> instance. /// </summary> /// <remarks> /// This method only creates an <see cref="SVR_AnimeGroup"/> instance. It does NOT save it to the database. /// </remarks> /// <param name="session">The NHibernate session.</param> /// <param name="mainSeries">The <see cref="SVR_AnimeSeries"/> whose name will represent the group (Optional. Pass <c>null</c> if not available).</param> /// <param name="mainAnimeId">The ID of the anime whose name will represent the group if <paramref name="mainSeries"/> is <c>null</c>.</param> /// <param name="now">The current date/time.</param> /// <returns>The created <see cref="SVR_AnimeGroup"/>.</returns> private SVR_AnimeGroup CreateAnimeGroup(SVR_AnimeSeries mainSeries, int mainAnimeId, DateTime now) { SVR_AnimeGroup animeGroup = new SVR_AnimeGroup(); string groupName = null; if (mainSeries != null) { animeGroup.Populate(mainSeries, now); groupName = mainSeries.GetSeriesName(); } else // The anime chosen as the group's main anime doesn't actually have a series { SVR_AniDB_Anime mainAnime = _aniDbAnimeRepo.GetByAnimeID(mainAnimeId); animeGroup.Populate(mainAnime, now); groupName = mainAnime.GetFormattedTitle(); } groupName = _truncateYearRegex.Replace(groupName, String.Empty); // If the title appears to end with a year suffix, then remove it animeGroup.GroupName = groupName; animeGroup.SortName = groupName; return(animeGroup); }
public static void Populate(this SVR_AnimeGroup agroup, SVR_AniDB_Anime anime, DateTime now) { agroup.Description = anime.Description; string name = anime.GetFormattedTitle(); agroup.GroupName = name; agroup.SortName = name; agroup.DateTimeUpdated = now; agroup.DateTimeCreated = now; }