public void Given_exisiting_github_repo()
        {
            var env = new TestEnv();
            env.GitHubClient.FileNames["https://github.com/foo/bar/"] = new List<string>
            {
                "File1.md",
                "File2.md"
            }.AsReadOnly();

            env.GitHubClient.Users["https://api.github.com/users/faa"] = new UserInfo
            {
                Name = "Faa"
            };

            env.GitHubClient.Repositories["https://api.github.com/repos/foo/bar"] = new RepositoryInfo
            {
                Name = "Bar",
                HtmlUrl = "https://github.com/foo/bar/",
                Owner = new UserRefInfo
                {
                    Url = "https://api.github.com/users/faa"
                }
            };

            var manager = env.CreateSubmissionGitHubGrabber();

            var feedback = new List<string>();
            _submission = manager.RetrieveGitHubModule("https://github.com/foo/bar/", feedback);
        }
Exemplo n.º 2
0
        public bool SubmitModule(SubmissionCandidate candidate, string contactName, string contactEmail, List<string> feedback)
        {
            var submission = new SubmissionDoc
            {
                SubmissionSource = "Website",
                Contact = new Contact
                {
                    Name = contactName,
                    Email = contactEmail
                },
                Candidate = candidate
            };

            _storage.Store(submission);

            return true;
        }
Exemplo n.º 3
0
        public ActionResult SubmitModule(SubmitModuleModel model)
        {
            if (ModelState.IsValid)
            {
                var feedback = new List<string>();
                var candidate = new SubmissionCandidate
                {
                    Title = model.Title,
                    Description = model.Description,
                    ProjectUrl = model.ProjectUrl,
                    ModuleID = model.ModuleID,
                    Content = new Content
                    {
                        Source = model.URL,
                        Type = model.Type
                    },
                    Author = new Contact
                    {
                        Name = model.AuthorName,
                        Email = model.AuthorEmail,
                        Uri = model.AuthorUrl
                    }
                };

                if (!_manager.SubmitModule(candidate, model.ContactName, model.ContactEmail, feedback))
                {
                    foreach (var item in feedback)
                    {
                        ModelState.AddModelError(String.Empty, item);
                    }
                }
                else
                {
                    return RedirectToAction("Index");
                }
            }
            return View(model);
        }