public void ThingSaveOrUpdate(Thing model) { var ctx = new DataBase.AppDbContext(); ctx.Things.Add(model); ctx.SaveChanges(); this.SendToAll(new ThingViewModel(model), "ThingSaveOrUpdate"); // Lets notify all client about the new thing! }
public void AddLikeToThing(int thingId, int score) { var ctx = new DataBase.AppDbContext(); var thing = ctx.Things.SingleOrDefault(t => t.Id.Equals(thingId)); thing.Likes.Add(new Like(){ Score = score}); ctx.SaveChanges(); this.SendToAll(new ThingViewModel(thing),"Liked"); // Lets notift all the client about the new like! }