public async Task<ActionResult> UpdateCacheFromGitHub() { string postedJson = string.Empty; try { using (var streamReader = new System.IO.StreamReader(Request.InputStream)) { postedJson = streamReader.ReadToEnd(); } GitHubPostedCommit posted = JsonConvert.DeserializeObject<GitHubPostedCommit>(postedJson); IEnumerable<BlogPost> newposts = Enumerable.Empty<BlogPost>(); //try //{ var gh = new Data.GitHub(); newposts = await gh.GetItemsForBranchCommit(posted); var localFileCache = new LocalFileCache(); //delete items if any. foreach (string blogUrlSlug in posted.RemovedPosts) { localFileCache.RemovePost(blogUrlSlug); } //} //catch (Exception) { } try { await SyncAzureIndex(newposts, posted.RemovedPosts); } catch (Exception) { } return new HttpStatusCodeResult(HttpStatusCode.OK); } catch (Exception ex) { return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message); } }
/// <summary> /// Retrieve all posts from the Git repo, and save to disk. /// </summary> public async Task RefreshCachedBlogPosts() { var github = new Data.GitHub(); await github.SaveAllBlogPostsFromGitHubToDisk(); }