Esempio n. 1
0
        private static void UploadTables(Inspection inspection)
        {
            var onlineInspection = OnlineDatabase.Inspections.FirstOrDefault(x => x.Hash == inspection.Hash);

            if (onlineInspection == null)
            {
                return;
            }

            onlineInspection.DateTimeDone    = inspection.DateTimeDone;
            onlineInspection.DateTimeStarted = inspection.DateTimeStarted;

            inspection.Answers.ToList().ForEach(x =>
            {
                var answer        = x.GetCleanModel();
                answer.Employee   = OnlineDatabase.Employees.FirstOrDefault(a => a.Hash == x.Employee.Hash);
                answer.Inspection = onlineInspection;
                answer.Question   = OnlineDatabase.Questions.FirstOrDefault(a => a.Hash == x.Question.Hash);

                if (x.Photo != null)
                {
                    var photo        = x.Photo.GetCleanModel();
                    photo.Inspection = onlineInspection;
                    photo.Answer     = answer;
                }

                OnlineDatabase.Answers.Add(answer);
            });

            OnlineDatabase.Inspections.AddOrUpdate(onlineInspection);

            OnlineDatabase.SaveChanges();
        }
        public async Task GetEntryAsync_ArtistId_ReturnsCorrectArtist()
        {
            var onlineDb = new OnlineDatabase(new ConsoleLogger());
            var task     = onlineDb.GetEntryAsync(Id.FromArtistNumber(1100), new CancellationToken(), new Progress <double>());
            var entry    = await task;

            Assert.IsFalse(task.IsFaulted);
            Assert.IsFalse(Entry.IsNullOrDefault(entry));
            var artist = entry as Artist;

            Assert.IsNotNull(artist);
            Assert.AreEqual("Arnold Schwarzenegger", artist.Name);
        }
        public async Task GetEntryAsync_TvSeriesId_ReturnsCorrectTvSeries()
        {
            var onlineDb = new OnlineDatabase(new ConsoleLogger());
            var task     = onlineDb.GetEntryAsync(Id.FromTvSeriesNumber(1668), new CancellationToken(), new Progress <double>());
            var entry    = await task;

            Assert.IsFalse(task.IsFaulted);
            Assert.IsFalse(Entry.IsNullOrDefault(entry));
            var tv = entry as TvSeries;

            Assert.IsNotNull(tv);
            Assert.AreEqual("Friends", tv.Name);
        }
        public async Task GetEntryAsync_MovieId_ReturnsCorrectMovie()
        {
            var onlineDb = new OnlineDatabase(new ConsoleLogger());
            var task     = onlineDb.GetEntryAsync(Id.FromMovieNumber(280), new CancellationToken(), new Progress <double>());
            var entry    = await task;

            Assert.IsFalse(task.IsFaulted);
            Assert.IsFalse(Entry.IsNullOrDefault(entry));
            var movie = entry as Movie;

            Assert.IsNotNull(movie);
            Assert.AreEqual("Terminator 2: Judgment Day", movie.Title);
        }