public async Task <ActionResult> Index([Bind(Include = "UserName")] TwitterReportLikesByPeriod twitterReportLikesByPeriod)
        {
            if (await TweetsReportGenerator.UpdateReportAsync(twitterReportLikesByPeriod))
            {
                await repository.SaveReportAsync(twitterReportLikesByPeriod);
            }

            ModelState.Clear();
            return(View());
        }
Exemplo n.º 2
0
        public async Task UpdateAsync_New_TwitterReportLikesPePeriod_With_Invalid_UserName()
        {
            //Arrange - create a report
            TwitterReportLikesByPeriod report = new TwitterReportLikesByPeriod();

            //Arrange - set incorrect name
            report.UserName = "******";

            //Act
            bool result = await TweetsReportGenerator.UpdateReportAsync(report);

            //Assert
            Assert.AreEqual(result, false);
        }
Exemplo n.º 3
0
        public void UpdateReport(TwitterReportLikesByPeriod report)
        {
            if (report == null)
            {
                return;
            }
            TwitterReportLikesByPeriod dbEntry = context.ReportLikesByPeriod.Find(report.ID);

            if (dbEntry == null)
            {
                return;
            }
            IEnumerable <TwitterReportPartLikesByHour> oldCollection = dbEntry.reportParts;

            TweetsReportGenerator.UpdateReport(dbEntry);
            if (oldCollection != null)
            {
                context.ReportPartLikesByHour.RemoveRange(oldCollection);
            }
            context.ReportPartLikesByHour.AddRange(dbEntry.reportParts);
            context.SaveChanges();
        }
Exemplo n.º 4
0
        public async Task UpdateReportAsync(TwitterReportLikesByPeriod report)
        {
            if (report == null)
            {
                return;
            }
            TwitterReportLikesByPeriod dbEntry = context.ReportLikesByPeriod.Find(report.ID);

            if (dbEntry == null)
            {
                return;
            }
            IEnumerable <TwitterReportPartLikesByHour> oldCollection = dbEntry.reportParts;
            await TweetsReportGenerator.UpdateReportAsync(dbEntry);

            if (oldCollection != null)
            {
                context.ReportPartLikesByHour.RemoveRange(oldCollection);
            }
            context.ReportPartLikesByHour.AddRange(dbEntry.reportParts);
            //db.ReportLikesByPeriod.Add(twitterReportLikesByPeriod);
            await context.SaveChangesAsync();
        }