public async Task <IActionResult> BolumIzlendi(int id) { var ub = new UBolumListe(); var bolum = await _context.Bolum.FindAsync(id); if (bolum != null) { ub.AnimeId = bolum.AnimeID; ub.BolumId = bolum.ID; ub.Puan = 0; ub.Tarih = DateTimeOffset.Now; ub.UserId = _userManager.GetUserId(User); _context.UBolumListe.Add(ub); var ua = await _context.UAnimeListe.FirstOrDefaultAsync(o => o.AnimeId == bolum.AnimeID); ua.Ekstra++; if (bolum.Adi.Contains("Bölüm Final")) { ua.ListType = 2; } await _context.SaveChangesAsync(); return(Json(ub)); } return(NotFound()); }
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)); }
public async Task <IActionResult> MalList(string user) { var MalList = await _parseFrom.MalListOf(user); var currUser = await _userManager.GetUserAsync(HttpContext.User); // var currUser = await _userManager.FindByEmailAsync("*****@*****.**"); _logger.LogInformation("MAL List for " + MalList.Myinfo.User_name + " fetched, C:" + MalList.Myinfo.User_completed + " W:" + MalList.Myinfo.User_watching + " H:" + MalList.Myinfo.User_onhold + " P:" + MalList.Myinfo.User_plantowatch); var l = new List <Data.Objects.MAL.List.XmlAnime>(); var dt = DateTimeOffset.Now; foreach (var xmla in MalList.Anime) { var anime = await _context.Anime.Select(o => new { mid = o.MalID, id = o.ID }).FirstOrDefaultAsync(i => i.mid == int.Parse(xmla.Series_animedb_id)); if (anime != null) { bool exists = true; var ua = await _context.UAnimeListe.FirstOrDefaultAsync(i => i.AnimeId == anime.id); if (ua == null) { ua = new UAnimeListe(); exists = false; } ua.AnimeId = anime.id; ua.Kaynak = "MAL-" + user; ua.Tarih = dt; ua.ListType = int.Parse(xmla.My_status); // 1 watching // 2 completed // 3 hold // 4 dropped // 6 planto ua.Puan = int.Parse(xmla.My_score); ua.User = currUser; if (exists == false) { _context.UAnimeListe.Add(ua); } var eps = int.Parse(xmla.My_watched_episodes); var bolumler = await _context.Bolum.Where(s => s.Bid < 0).ToListAsync(); if (ua.ListType == 1) { bolumler = await _context.Bolum.OrderBy(o => o.Bid).Where(o => o.AnimeID == anime.id).Take(eps).ToListAsync(); } else if (ua.ListType == 2) { bolumler = await _context.Bolum.Where(o => o.AnimeID == anime.id).ToListAsync(); } foreach (var b in bolumler) { bool bexists = true; var ub = await _context.UBolumListe.FirstOrDefaultAsync(i => i.BolumId == b.ID); if (ub == null) { ub = new UBolumListe(); bexists = false; } ub.AnimeId = anime.id; ub.BolumId = b.ID; ub.Puan = ua.Puan; ub.Tarih = dt; ub.User = currUser; if (bexists == false) { _context.UBolumListe.Add(ub); } } var r = await _context.SaveChangesAsync(); } else { l.Add(xmla); _logger.LogWarning(currUser.UserName + "'nin listesinde <" + user + "> " + xmla.Series_title + " [" + xmla.Series_animedb_id + "] veritabaninda bulunamadi!"); } } return(Json(l)); }