Ejemplo n.º 1
0
        private static async void TrendingCommand(TrendingOptions trendingOptions, TaskCompletionSource <object> taskCompletionSource)
        {
            IEnumerable <IEntity> trendingMedia = null;

            if (trendingOptions.Anime)
            {
                trendingMedia = await KitsuAPI.GetTrendingAnimeAsync(kitsuSession);
            }
            else if (trendingOptions.Drama)
            {
                //not implemented
                trendingMedia = new IEntity[] { };
            }
            else if (trendingOptions.Manga)
            {
                trendingMedia = await KitsuAPI.GetTrendingMangaAsync(kitsuSession);
            }
            else
            {
                taskCompletionSource.SetResult(null);
                return;
            }

            foreach (var item in trendingMedia)
            {
                PrintMedia(item);
            }

            taskCompletionSource.SetResult(null);
        }
Ejemplo n.º 2
0
        private static async void GetCommand(GetOptions authOptions, TaskCompletionSource <object> taskCompletionSource)
        {
            try
            {
                if (authOptions.User)
                {
                    User user = await KitsuAPI.GetUserByIDAsync(authOptions.Id, kitsuSession);

                    UserAttributes userAttributes = user.Attributes.As <UserAttributes>();

                    Console.WriteLine("-");
                    Console.WriteLine("Name: {0}", userAttributes.Name);
                    Console.WriteLine("ID: {0}", user.Id);
                    Console.WriteLine("--About:");
                    Console.WriteLine(userAttributes.About);
                    Console.WriteLine("--");
                    Console.WriteLine("-");
                }
                else
                {
                    IEntity media = null;

                    if (authOptions.Anime)
                    {
                        media = await KitsuAPI.GetAnimeByIDAsync(authOptions.Id, kitsuSession);
                    }
                    else if (authOptions.Manga)
                    {
                        media = await KitsuAPI.GetMangaByIDAsync(authOptions.Id, kitsuSession);
                    }
                    else if (authOptions.Drama)
                    {
                    }

                    if (media != null)
                    {
                        PrintMedia(media);
                    }
                }

                taskCompletionSource.SetResult(null);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error occurred.");
                Console.Error.WriteLine(ex.ToString());

                taskCompletionSource.SetException(ex);
            }
        }