Beispiel #1
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Url,HtmlUrl,CloneUrl,GitUrl,SshUrl,SvnUrl,MirrorUrl,Name,FullName,Description,Homepage,Language,Private,Fork,ForksCount,WatchersCount,MasterBranch,OpenIssuesCount,PushedAt,CreatedAt,UpdatedAt,HasIssues,HasWiki,HasDownloads")] Repo repo)
        {
            if (ModelState.IsValid)
            {
                db.Repo.Add(repo);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(repo));
        }
Beispiel #2
0
        public async Task WriteReadHostTests()
        {
            var e = new WatchEntity {
                WatchId             = Guid.NewGuid(),
                Emails              = Guid.NewGuid().ToString(),
                Host                = Guid.NewGuid().ToString(),
                PingIntervalSeconds = 1000
            };
            var result = await RepoContext.AddAsync(e);

            await RepoContext.SaveChangesAsync();

            Assert.AreEqual(e.WatchId, result.Entity.WatchId);
        }
Beispiel #3
0
        public async Task <ActionResult> Refresh()
        {
            db.Database.ExecuteSqlCommand("delete from WeeklyHashes");
            db.Database.ExecuteSqlCommand("delete from DayCounts");
            db.Database.ExecuteSqlCommand("delete from WeeklyCommitActivities");
            db.Database.ExecuteSqlCommand("delete from PunchCardPoints");
            db.Database.ExecuteSqlCommand("delete from Participations");
            db.Database.ExecuteSqlCommand("delete from Contributors");
            db.Database.ExecuteSqlCommand("delete from CodeFrequencies");
            db.Database.ExecuteSqlCommand("delete from Repoes");
            db.Database.ExecuteSqlCommand("delete from Users");

            var github = new GitHubClient(new ProductHeaderValue(Globals.GitHubAppName))
            {
                Credentials = new Credentials("dstrockis", "password")
            };
            var repos = await github.Repository.GetAllForOrg(Globals.GitHubOrg);

            var model = new List <Repo>();

            foreach (var repo in repos)
            {
                var contributors = await github.Repository.Statistics.GetContributors(repo.Owner.Login, repo.Name);

                var commitActivity = await github.Repository.Statistics.GetCommitActivity(repo.Owner.Login, repo.Name);

                var codeFrequency = await github.Repository.Statistics.GetCodeFrequency(repo.Owner.Login, repo.Name);

                var participation = await github.Repository.Statistics.GetParticipation(repo.Owner.Login, repo.Name);

                var punchCard = await github.Repository.Statistics.GetPunchCard(repo.Owner.Login, repo.Name);

                var newRepo = new Repo(repo, contributors, commitActivity, codeFrequency, participation, punchCard);
                model.Add(newRepo);
                if (ModelState.IsValid)
                {
                    db.Repo.Add(newRepo);
                }
            }
            db.SaveChangesAsync();
            return(RedirectToAction("Index", new { origin = "Refresh" }));
            //return RedirectToRoute(new { controller = "Home", action = "About" });
        }
Beispiel #4
0
        public async Task DeleteHostTests()
        {
            var e = new WatchEntity
            {
                WatchId             = Guid.NewGuid(),
                Emails              = Guid.NewGuid().ToString(),
                Host                = Guid.NewGuid().ToString(),
                PingIntervalSeconds = 1000
            };

            var result = await RepoContext.AddAsync(e);

            await RepoContext.SaveChangesAsync();

            Assert.AreEqual(e.WatchId, result.Entity.WatchId);

            await RepoContext.Remove(e.WatchId);

            var e2 = await RepoContext.GetItem(e.WatchId);

            Assert.IsNull(e2);
        }