Exemplo n.º 1
0
        public async Task <IActionResult> DeleteFileEpisode(string token, string hash, int episodeid)
        {
            try
            {
                SessionInfoWithError s = await VerifyTokenAsync(token);

                if (s.Error != null)
                {
                    return(s.Error);
                }
                WebCache_CrossRef_File_Episode ep = await _db.CrossRef_File_Episodes.FirstOrDefaultAsync(a => a.CrossRef_File_EpisodeID == episodeid && a.Hash == hash && a.AniDBUserId == s.AniDBUserId);

                if (ep == null)
                {
                    return(StatusCode(404, "CrossRef Not Found"));
                }
                _db.Remove(ep);
                await _db.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"DELETEFILEEPISODE with Token={token} Hash={hash} EpisodeId={episodeid}");
                return(StatusCode(500));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddFileEpisode(string token, [FromBody] CrossRef_File_Episode episode)
        {
            try
            {
                SessionInfoWithError s = await VerifyTokenAsync(token);

                if (s.Error != null)
                {
                    return(s.Error);
                }
                WebCache_CrossRef_File_Episode ep = await _db.CrossRef_File_Episodes.FirstOrDefaultAsync(a => a.CrossRef_File_EpisodeID == episode.CrossRef_File_EpisodeID && a.AniDBUserId == s.AniDBUserId);

                if (ep == null)
                {
                    ep = new WebCache_CrossRef_File_Episode();
                    _db.Add(ep);
                }

                ep.FillWith(episode);
                ep.AniDBUserId = s.AniDBUserId;
                await _db.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"ADDFILEEPISODE with Token={token}");
                return(StatusCode(500));
            }
        }