Пример #1
0
        public InMemoryRepository(IMovieIDResolutionService idResolutionService, bool seed = true)
        {
            if (seed)
            {
                _movies.AddRange(new List <Movie>()
                {
                    new Movie()
                    {
                        Id = ++_movieUniqueCount, Title = "Jurassic World", Year = 2015
                    },
                    new Movie()
                    {
                        Id = ++_movieUniqueCount, Title = "Deadpool", Year = 2016
                    },
                    new Movie()
                    {
                        Id = ++_movieUniqueCount, Title = "Iron Man", Year = 2008
                    },
                });
            }

            _idResolution = idResolutionService;
        }
Пример #2
0
        private static int GetExternalMovieId(IMovieIDResolutionService ideService, String title, ushort year)
        {
            int id = -1;

            try
            {
                var task = ideService.GetMovieIdAsync(title, year);
                task.Wait();
                id = task.Result;
            }
            catch (AggregateException e)
            {
                // swallow exception as we're default to -1
                if (e.InnerExceptions.First() is ArgumentException)
                {
                    throw e.InnerExceptions.First() as ArgumentException;
                }

                System.Diagnostics.Debug.Assert(false, "unexpected exception");
            }

            return(id);
        }
Пример #3
0
 public DbMovieRepository(IMovieIDResolutionService idResolutionService)
 {
     _idResolutionService = idResolutionService;
 }