public async Task <bool> PushAnimeDetailsToMal(IAnimeDetailsJson details, string username, string password, bool canCache = true) { var useDetails = _jsonMapper.ConvertJsonAnimeDetailsToAnimeDetails(details); bool result; Log.Information("Received request to update {AnimeId} for {username}", details.AnimeId, username); var userlist = await _animeListRetriever.GetAnimeList(username); var item = userlist.Anime.FirstOrDefault(t => t.SeriesId == details.AnimeId); //The item doesn't exists - Use the add new method if (item == null) { result = await UpdateAnimeDetails(useDetails, username, password, canCache); Log.Information("Added {AnimeId} for {username}", details.AnimeId, username); } else { result = await UpdateAnimeDetails(useDetails, username, password, canCache, true); if (result) { Log.Information("Updated {AnimeId} for {username}", details.AnimeId, username); } else { Log.Warning("Update of {AnimeId} for {username} failed", details.AnimeId, username); } } return(result); }
/// <summary> /// Retrieve user list for a spesific user /// </summary> /// <param name="username">MAL Username</param> /// <returns>List containing User information and all anime in the user's list</returns> public async Task <HttpResponseMessage> Get(string username) { var stopWatch = new Stopwatch(); stopWatch.Start(); Log.Information("Received request for {username}'s anime list", username); var userlist = await _animeListRetriever.GetAnimeList(username); var jsonList = _mapper.ConvertMyListToJson(userlist); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(jsonList, Encoding.UTF8, "application/json"); stopWatch.Stop(); Log.Information("Sent response for {username}'s list. Processing took {duration}", username, stopWatch.Elapsed); return(response); }