Beispiel #1
0
 public void AddShowTest()
 {
     Assert.Empty(repo.GetAllShows());
     repo.Add(new Show {
         name = "The Super Awesome Show", date = DateTime.Parse("4/20/2018 4:20PM"), cost = 1, minAge = 18, type = ShowType.Public, description = "This show really will be the best, that is why it is the super awsome show."
     });
     Assert.Single(repo.GetAllShows());
 }
        public void Save(IShow show, out bool success)
        {
            Checks.Argument.IsNotNull(show, "show");

            success = false;

            if (null == _repo.FindById(show.Id))
            {
                try {
                    _repo.Add(show);
                    success = true;
                }
                catch (Exception ex) {
                    success = false;
                }
            }
        }
Beispiel #3
0
        public async Task <ShowViewModel> AddShow(string name, DateTime showDate, TimeSpan showDuration, int ticketCount)
        {
            var show = new Show()
            {
                Id          = Guid.NewGuid(),
                Name        = name,
                ShowDate    = showDate,
                Duration    = showDuration,
                TicketCount = ticketCount
            };

            try
            {
                return(await _showRepository.Add(show));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(null);
            }
        }
Beispiel #4
0
 public IActionResult ShowCreate(Show show)
 {
     showRepo.Add(show);
     ViewData["Message"] = "Show Added!";
     return(View("ShowList", showRepo.GetAllShows()));
 }
Beispiel #5
0
        public async Task Run()
        {
            var maxShowId = await showRepository.GetMaxShowId();

            int  pageNumber = GetPageNumberofId(maxShowId);
            bool firstLoop  = true;

            logger.LogInformation($"Scraper starting");

            while (true)
            {
                var newShows = await GetShowsFromService(pageNumber);

                if (newShows.Count == 0)
                {
                    break;
                }

                // Import newest shows from the last imported page
                if (firstLoop)
                {
                    firstLoop = false;
                    newShows  = newShows.Where(s => s.Id > maxShowId).ToList();
                    if (newShows.Count == 0)
                    {
                        pageNumber++;
                        continue;
                    }
                }

                var actorIds  = newShows.SelectMany(s => s.Actors, (a, b) => b.Id).Distinct();
                var newActors = await FindNewPeople(newShows);

                foreach (var newActor in newActors)
                {
                    var p = new dataModels.Person {
                        Id = newActor.Id, Name = newActor.Name, Birthday = newActor.Birthday
                    };
                    await personRepository.Add(p);
                }

                foreach (var newShow in newShows)
                {
                    var show = new dataModels.Show {
                        Id = newShow.Id, Name = newShow.Name, ShowPeople = new List <dataModels.ShowPerson>()
                    };
                    foreach (var actor in newShow.Actors)
                    {
                        show.ShowPeople.Add(new dataModels.ShowPerson {
                            ShowId = show.Id, PersonId = actor.Id
                        });
                    }

                    await showRepository.Add(show);
                }
                logger.LogInformation("Saving the new shows to db");
                await showRepository.Save();

                pageNumber++;
            }
        }