Beispiel #1
0
        // GET: Projects/Project
        public async Task <ActionResult> Project(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ProjectModel projectModel = PC.ProjectList.FirstOrDefault(modelItem => modelItem.Id == id);

            if (projectModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            LoginModel loginModel = LC.UserList.FirstOrDefault(loginItem => loginItem.ID == projectModel.UserId);

            if (loginModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            ProjectJsonObject projectJson = new ProjectJsonObject(projectModel.Name.Trim(), projectModel.ImagePath, projectModel.GitHubUrl, projectModel.SiteUrl, projectModel.OtherUrl, id);

            return(View(projectJson));
        }
        private void Clone()
        {
            _projectJsonClone = (JObject)ProjectJsonObject.DeepClone();

            if (LaunchSettingsObject != null)
            {
                _launchSettingsJsonClone = (JObject)LaunchSettingsObject.DeepClone();
            }


            if (VsProjectFile != null)
            {
                _xprojBackup = new StringBuilder();
                using (var writer = new StringWriter(_xprojBackup))
                {
                    VsProjectFile.Xml.Save(writer);
                    writer.Flush();
                }
            }
        }
Beispiel #3
0
        public async Task <String> GetGitCommits(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            ProjectModel projectModel = PC.ProjectList.FirstOrDefault(modelItem => modelItem.Id == id);

            if (projectModel == null)
            {
                return(GetCommitsToString(new ProjectJsonObject().Commits));
            }

            LoginModel loginModel = LC.UserList.FirstOrDefault(loginItem => loginItem.ID == projectModel.UserId);

            if (loginModel == null)
            {
                return(GetCommitsToString(new ProjectJsonObject().Commits));
            }

            HttpClient httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Add("User-Agent", "Franks Server");
            string            httprequeststring = "Https://api.github.com/repos/" + loginModel.UserName.Trim() + "/" + projectModel.Name.Trim() + "/commits";
            ProjectJsonObject projectJson;

            try
            {
                var apiCallResponse = await httpClient.GetStringAsync(httprequeststring);

                projectJson = new ProjectJsonObject(apiCallResponse, projectModel.Name, projectModel.Description, projectModel.GitHubUrl, projectModel.SiteUrl, projectModel.OtherUrl, projectModel.ImagePath, projectModel.Id);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                projectJson = new ProjectJsonObject(projectModel.Name.Trim(), projectModel.ImagePath, projectModel.GitHubUrl, projectModel.SiteUrl, projectModel.OtherUrl, id);
            }
            return(GetCommitsToString(projectJson.Commits));
        }