本文整理汇总了C#中JMMServer.Repositories.AnimeSeriesRepository.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# AnimeSeriesRepository.Delete方法的具体用法?C# AnimeSeriesRepository.Delete怎么用?C# AnimeSeriesRepository.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMMServer.Repositories.AnimeSeriesRepository
的用法示例。
在下文中一共展示了AnimeSeriesRepository.Delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteAnimeSeries
/// <summary>
/// Delete a series, and everything underneath it (episodes, files)
/// </summary>
/// <param name="animeSeriesID"></param>
/// <param name="deleteFiles">also delete the physical files</param>
/// <returns></returns>
public string DeleteAnimeSeries(int animeSeriesID, bool deleteFiles, bool deleteParentGroup)
{
try
{
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
VideoLocalRepository repVids = new VideoLocalRepository();
AnimeGroupRepository repGroups = new AnimeGroupRepository();
AnimeSeries ser = repAnimeSer.GetByID(animeSeriesID);
if (ser == null) return "Series does not exist";
int animeGroupID = ser.AnimeGroupID;
foreach (AnimeEpisode ep in ser.GetAnimeEpisodes())
{
foreach (VideoLocal vid in ep.GetVideoLocals())
{
if (deleteFiles)
{
logger.Info("Deleting video local record and file: {0}", vid.FullServerPath);
if (!File.Exists(vid.FullServerPath)) return "File could not be found";
File.Delete(vid.FullServerPath);
}
CommandRequest_DeleteFileFromMyList cmdDel = new CommandRequest_DeleteFileFromMyList(vid.Hash, vid.FileSize);
cmdDel.Save();
repVids.Delete(vid.VideoLocalID);
}
repEps.Delete(ep.AnimeEpisodeID);
}
repAnimeSer.Delete(ser.AnimeSeriesID);
// finally update stats
AnimeGroup grp = repGroups.GetByID(animeGroupID);
if (grp != null)
{
if (grp.GetAllSeries().Count == 0)
{
DeleteAnimeGroup(grp.AnimeGroupID, false);
}
else
{
grp.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
StatsCache.Instance.UpdateUsingGroup(grp.TopLevelAnimeGroup.AnimeGroupID);
}
}
return "";
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
return ex.Message;
}
}