コード例 #1
0
ファイル: OmdbGrabber.cs プロジェクト: davitg/Wtow
        public async void GrabByImdbIds(string[] imdbIds)
        {
            List <Title> titles;

            titles = await _titleService.GetAllTitles();

            foreach (string imdbId in imdbIds)
            {
                try
                {
                    var exists = titles.Where(t => t.ImdbId == imdbId).Any();

                    if (exists)
                    {
                        continue;
                    }

                    Console.WriteLine($"Calling OMDb APi for '{imdbId}'");
                    _log.Info($"Calling OMDb APi for '{imdbId}'");

                    var title = _apiParser.GetTitleByImdbId(imdbId).Result;

                    if (!String.IsNullOrEmpty(title.Name))
                    {
                        Console.WriteLine($"Saving Title Name:'{title.Name}'  IMDb Id:'{imdbId}'");
                        _log.Info($"Saving Title Name:'{title.Name}'  IMDb Id:'{imdbId}'");
                        _titleService.AddTitle(title);
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.ToString());
                }
            }
        }
コード例 #2
0
        public void PrepareTitles(IList <SelectListItem> items, bool withSpecialDefaultItem = true, string defaultItemText = null)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            //prepare available activity log types
            var availableTitles = _titleService.GetAllTitles();

            foreach (var title in availableTitles)
            {
                items.Add(new SelectListItem {
                    Value = title.Id.ToString(), Text = title.TitleNameTH
                });
            }

            //insert special item for the default value
            PrepareDefaultItem(items, withSpecialDefaultItem, defaultItemText);
        }
コード例 #3
0
 public List <TitleCreateDto> GetAllTitles()
 {
     return(_titleservice.GetAllTitles());
 }