Permalink
Browse files

moving xref removal

moved the removal of any potentially existing xrefs to the creation of the necessary command, keeping the purpose the removal was inteded for but keeping the ability to link 1 file to x episodes

Co-Authored-By: Thomas Baer <da3dsoul@gmail.com>
  • Loading branch information...
Baine and da3dsoul committed Mar 2, 2018
1 parent 9ccdb32 commit 21d5e72c4b3d185746f9209de2fcffcdcf4c9755
@@ -761,6 +761,16 @@ public string SetVariationStatusOnFile(int videoLocalID, bool isVariation)
}
}

private void RemoveXRefsForFile(int VideoLocalID)
{
SVR_VideoLocal vlocal = RepoFactory.VideoLocal.GetByID(VideoLocalID);
List<CrossRef_File_Episode> fileEps = RepoFactory.CrossRef_File_Episode.GetByHash(vlocal.Hash);

foreach (CrossRef_File_Episode fileEp in fileEps)
RepoFactory.CrossRef_File_Episode.Delete(fileEp.CrossRef_File_EpisodeID);

}

public string AssociateSingleFile(int videoLocalID, int animeEpisodeID)
{
try
@@ -775,6 +785,7 @@ public string AssociateSingleFile(int videoLocalID, int animeEpisodeID)
if (ep == null)
return "Could not find episode record";

RemoveXRefsForFile(videoLocalID);
var com = new CommandRequest_LinkFileManually(videoLocalID, animeEpisodeID);
com.Save();
return string.Empty;
@@ -802,17 +813,15 @@ public string AssociateSingleFile(int videoLocalID, int animeEpisodeID)
return "Could not find anime series record";
for (int i = startEpNum; i <= endEpNum; i++)
{
List<AniDB_Episode> anieps =
RepoFactory.AniDB_Episode.GetByAnimeIDAndEpisodeNumber(ser.AniDB_ID, i);
if (anieps.Count == 0)
AniDB_Episode aniep = RepoFactory.AniDB_Episode.GetByAnimeIDAndEpisodeNumber(ser.AniDB_ID, i)[0];
if (aniep == null)
return "Could not find the AniDB episode record";

AniDB_Episode aniep = anieps[0];

SVR_AnimeEpisode ep = RepoFactory.AnimeEpisode.GetByAniDBEpisodeID(aniep.EpisodeID);
if (ep == null)
return "Could not find episode record";

RemoveXRefsForFile(videoLocalID);
var com = new CommandRequest_LinkFileManually(videoLocalID, ep.AnimeEpisodeID);
com.Save();
}
@@ -859,6 +868,7 @@ public string AssociateSingleFile(int videoLocalID, int animeEpisodeID)
if (ep == null)
return "Could not find episode record";

RemoveXRefsForFile(videoLocalID);
var com = new CommandRequest_LinkFileManually(videoLocalID, ep.AnimeEpisodeID);
if (singleEpisode)
{
@@ -60,11 +60,6 @@ public CommandRequest_LinkFileManually(int vidLocalID, int episodeID)

public override void ProcessCommand()
{
List<CrossRef_File_Episode> fileEps = RepoFactory.CrossRef_File_Episode.GetByHash(vlocal.Hash);

foreach (CrossRef_File_Episode fileEp in fileEps)
RepoFactory.CrossRef_File_Episode.Delete(fileEp.CrossRef_File_EpisodeID);

CrossRef_File_Episode xref = new CrossRef_File_Episode();
try
{

0 comments on commit 21d5e72

Please sign in to comment.