Example #1
0
        public static int Execute(FindOptions options)
        {
            try
            {
                Creator creator = MarvelApi.GetCreatorAsync(options.Url, options.Id).Result;

                Console.WriteLine(
                    "    Id FullName                                           Modified Comics Series");
                Console.WriteLine(
                    "--------------------------------------------------------------------------------");
                Console.WriteLine(
                    $"{creator.Id,6} {creator.FullName,-30}{creator.Modified,30}{creator.ComicsTotal,6}{creator.SeriesTotal,6}");
                if (options.ShowNotes && creator.Note != null)
                {
                    Console.WriteLine($"Note: [{creator.Note.Text}]");
                }

                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error retrieving creator:");
                Console.WriteLine(e.Message);
                return(-1);
            }
        }
        public async Task <IActionResult> Index([FromQuery] string searchString,
                                                [FromServices] MarvelApi marvelApi,
                                                [FromServices] MongoDatabase mongoDatabase)
        {
            _logger.LogInformation("Listing characters");

            var apiCharacters = await marvelApi.GetCharacters(searchString);

            var likedCharacters = await mongoDatabase.GetLikes();

            for (int i = 0; i < apiCharacters.Count; i++)
            {
                var currentCharacter = apiCharacters.ToArray()[i];

                var liked = likedCharacters.FirstOrDefault(x => x.Id == currentCharacter.Id);
                if (liked != null)
                {
                    //foi liked
                    currentCharacter.Liked = true;
                }
            }



            return(Ok(apiCharacters));
        }
 public static int Execute(AddNoteOptions options)
 {
     try
     {
         MarvelApi.AddNoteAsync(options.Url, options.CreatorId, options.NoteText).Wait();
         return(0);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error adding note:");
         Console.WriteLine(e.Message);
         return(-1);
     }
 }
 public static int Execute(DeleteNoteOptions options)
 {
     try
     {
         MarvelApi.DeleteNoteAsync(options.Url, options.CreatorId).Wait();
         return(0);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error deleting note:");
         Console.WriteLine(e.Message);
         return(-1);
     }
 }
Example #5
0
        public static int Execute(ListOptions options)
        {
            try
            {
                DateTime?modifiedSince = null;
                if (!String.IsNullOrEmpty(options.ModifiedSince))
                {
                    // Parses using the same rules as when printing date to screen.
                    // This should allow you to copy-paste date from the output directly to the command line,
                    // whatever locale you are in.
                    modifiedSince = DateTime.Parse(options.ModifiedSince);
                }
                GetCreatorsResponse response = MarvelApi.GetCreatorsAsync(
                    options.Url,
                    options.FullName,
                    modifiedSince,
                    options.Page,
                    options.Size,
                    options.Sorting).Result;
                Console.WriteLine($"Page number: {response.PageNumber}");
                Console.WriteLine($"Page size: {response.PageSize}");
                Console.WriteLine($"Showing {response.Count} of total {response.Total} results.");
                Console.WriteLine();
                Console.WriteLine(
                    "    Id FullName                                           Modified Comics Series");
                Console.WriteLine(
                    "--------------------------------------------------------------------------------");
                foreach (var creator in response.Creators)
                {
                    Console.WriteLine(
                        $"{creator.Id,6} {creator.FullName,-30}{creator.Modified,30}{creator.ComicsTotal,6}{creator.SeriesTotal,6}");
                    if (options.ShowNotes && creator.Note != null)
                    {
                        Console.WriteLine($"Note: [{creator.Note.Text}]");
                    }
                }

                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error retrieving creators:");
                Console.WriteLine(e.Message);
                return(-1);
            }
        }
Example #6
0
        public async Task <IActionResult> Find()
        {
            var marvel = new MarvelApi();

            var apiResultCharacters = await marvel.GetCharacters();

            var apiResultComics = await marvel.GetComics();

            var apiResultCreators = await marvel.GetCreators();

            var apiResultSeries = await marvel.GetSeries();


            var findVM = new FindVM()
            {
                Characters = apiResultCharacters.Data.Results.AsEnumerable(),
                Comics     = apiResultComics.Data.Results.AsEnumerable(),
                Creators   = apiResultCreators.Data.Results.AsEnumerable(),
                Series     = apiResultSeries.Data.Results.AsEnumerable()
            };

            return(View(findVM));
        }
Example #7
0
        public async Task <IActionResult> CreatorDetails(int?id, string name)
        {
            MarvelApi          marvel     = new MarvelApi();
            CreatorDataWrapper apiCreator = new CreatorDataWrapper();

            if (id == null && name == null)
            {
                return(NotFound());
            }

            if (id != null)
            {
                apiCreator = await marvel.GetCreatorById(id);
            }

            if (name != null)
            {
                apiCreator = await marvel.GetCreatorByName(name);
            }

            IEnumerable <Creator> creatorList = apiCreator.Data.Results;

            return(View(creatorList));
        }
Example #8
0
        public async Task <IActionResult> ComicDetails(int?id, string title)
        {
            MarvelApi        marvel   = new MarvelApi();
            ComicDataWrapper apiComic = new ComicDataWrapper();

            if (id == null && title == null)
            {
                return(NotFound());
            }

            if (id != null)
            {
                apiComic = await marvel.GetComicId(id);
            }

            if (title != null)
            {
                apiComic = await marvel.GetComicByTitle(title);
            }

            IEnumerable <Comic> comicList = apiComic.Data.Results;

            return(View(comicList));
        }
Example #9
0
        public async Task <IActionResult> SerieDetails(int?id, string title)
        {
            MarvelApi         marvel   = new MarvelApi();
            SeriesDataWrapper apiSerie = new SeriesDataWrapper();

            if (id == null && title == null)
            {
                return(NotFound());
            }

            if (id != null)
            {
                apiSerie = await marvel.GetSerieById(id);
            }

            if (title != null)
            {
                apiSerie = await marvel.GetSerieByTitle(title);
            }

            IEnumerable <Series> seriesList = apiSerie.Data.Results;

            return(View(seriesList));
        }
 public MainWindow()
 {
     InitializeComponent();
     marvelApi = new MarvelApi();
 }