Example #1
0
        /// <summary>
        /// Update cached details for the specified project
        /// </summary>
        /// <param name="project">Project to update</param>
        public void UpdateProject(ProjectModel project)
        {
            bool dirty = false;
            dirty |= UpdateReadme(project);
            dirty |= UpdateRepository(project);

            if (dirty)
                _projectRepository.Save(project);
        }
Example #2
0
        /// <summary>
        /// Updates the readme for the specified project
        /// </summary>
        /// <param name="project">The project to update</param>
        /// <returns><c>true</c> if any data was updated</returns>
        private bool UpdateReadme(ProjectModel project)
        {
            if (string.IsNullOrWhiteSpace(project.ReadmeUrl))
                return false;

            using (var client = new WebClient())
            {
                client.Encoding = Encoding.UTF8;
                var readmeSource = client.DownloadString(project.ReadmeUrl);
                project.Readme = _markdown.Parse(readmeSource);
                return true;
            }
        }
 /// <summary>
 /// Saves the entity to the database
 /// </summary>
 /// <param name="entity">The entity to save</param>
 /// <param name="isNew"><c>true</c> to do an INSERT or <c>false</c> to do an UPDATE</param>
 public void Save(ProjectModel entity, bool isNew)
 {
     throw new NotImplementedException();
 }
Example #4
0
        /// <summary>
        /// Updates the repository information for the specified project
        /// </summary>
        /// <param name="project">The project to update</param>
        private bool UpdateRepository(ProjectModel project)
        {
            if (string.IsNullOrWhiteSpace(project.RepositoryUrl))
                return false;

            var uri = new Uri(project.RepositoryUrl);
            var info = _repositoryManager.GetRepositoryInfo(uri);
            // TODO: Use AutoMapper here
            project.Created = info.Created;
            project.Updated = info.Updated;
            project.Forks = info.Forks;
            project.Watchers = info.Watchers;
            project.OpenIssues = info.OpenIssues;
            return true;
        }