Beispiel #1
0
        public IActionResult SearchAnimatedGifs(string searchText, int searchLimit, string language)
        {
            PictureViewModel model = new PictureViewModel();

            try
            {
                var result = _giphyAService.GetGifsByCriteria(searchText, searchLimit, language);
                if (result != null)
                {
                    foreach (var item in result.Data)
                    {
                        if (item != null)
                        {
                            model.Pictures.Add(new Picture()
                            {
                                SourceUrl = item.Images?.OriginalStill?.Url,
                                FileName  = item.Images?.Downsized?.Url,
                                Height    = Convert.ToInt32(item.Images?.Downsized?.Height),
                                Width     = Convert.ToInt32(item.Images?.Downsized?.Width)
                            });
                        }
                    }
                }
                return(View(model));
            }
            catch (Exception)
            {
                model.IsError = true;
                model.Message = "Unexpected error ocurred while retrieving Animated Gifs from Giphy Website. Try again later!";
                return(View(model));
            }
        }
Beispiel #2
0
        public IActionResult SearchAnimatedGifs(string searchText, int searchLimit, string language)
        {
            PictureViewModel model = new PictureViewModel();
            var result             = _giphyAService.GetGifsByCriteria(searchText, searchLimit, language);

            if (result != null)
            {
                foreach (var item in result.Data)
                {
                    if (item != null)
                    {
                        model.Pictures.Add(new Picture()
                        {
                            FileName  = getFileFromSourceUrl(item.BitlyGifUrl),
                            SourceUrl = item.BitlyGifUrl,
                            Height    = Convert.ToInt32(item.Images?.Downsized?.Height),
                            Width     = Convert.ToInt32(item.Images?.Downsized?.Width)
                        });
                    }
                }
            }
            return(Json(model));
        }