Exemplo n.º 1
0
        public async Task <IActionResult> FavListMe(int id, int kind, int point)
        {
            var exists = await _context.Anime.AnyAsync(o => o.ID == id);

            if (exists == false)
            {
                return(NotFound());
            }

            var ua = await _context.UAnimeListe.FirstOrDefaultAsync(i => i.AnimeId == id);

            if (ua != null)
            {
                ua.ListType = kind;
                ua.Puan     = point;
            }
            else
            {
                ua          = new UAnimeListe();
                ua.AnimeId  = id;
                ua.Kaynak   = "Animeci";
                ua.ListType = kind;
                ua.Puan     = point;
                ua.Tarih    = DateTimeOffset.Now;
                ua.UserId   = _userManager.GetUserId(User);
                _context.UAnimeListe.Add(ua);
                if (kind == 2)
                {
                    var bl = await _context.Bolum.Where(i => i.AnimeID == id).ToListAsync();

                    foreach (var b in bl)
                    {
                        var ub = await _context.UBolumListe.FirstOrDefaultAsync(i => i.BolumId == b.ID);

                        if (ub == null)
                        {
                            ub         = new UBolumListe();
                            ub.AnimeId = b.AnimeID;
                            ub.BolumId = b.ID;
                            ub.Puan    = point;
                            ub.Tarih   = DateTimeOffset.Now;
                            ub.UserId  = _userManager.GetUserId(User);
                            _context.UBolumListe.Add(ub);
                        }
                    }
                }
            }

            await _context.SaveChangesAsync();

            return(Json(ua));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> JTA()
        {
            var list = await _parseFrom.GetJSONList() as List <JAnime>;

            _logger.LogWarning(1, "Adding `FetchAnime` jobs @{listc}", list.Count);
            foreach (var j in list)
            {
                var qj = new QueJobs();
                qj.job_class = "FetchAnime";
                qj.args      = JsonConvert.SerializeObject(j);
                _context.QueJobs.Add(qj);
            }
            var r = await _context.SaveChangesAsync();

            _logger.LogWarning(1, "Added `FetchAnime` jobs {r}/{listc}", r, list.Count);
            return(Json(list.Count));
        }