Now we've got the basics of the layout done and we are ready to get some code in here for lighting it all up. Let's start by creating the hub for the article management. Add a folder called Hubs
in the root of the project, and then create a new class called ArticleHub
in this folder. Add the following code in the new class:
using System; using System.Collections.Generic; using Chapter3.DAL; using Chapter3.Models.News; using Microsoft.AspNet.SignalR; namespace Chapter3.Hubs { public class ArticleHub : Hub { ArticleContext _articleContext; public ArticleHub() { _articleContext = new ArticleContext(); } protected override void Dispose(bool disposing) { if (disposing) { _articleContext.Dispose(); } base.Dispose(disposing); } public IEnumerable<Article> GetArticles() { return _articleContext.GetArticles(); ...