public void GetByGroupTest() { var comment = new Comment { AddedDate = DateTime.Now, CommentId = Guid.NewGuid(), GroupName = "eternity", CommentText = "Hi all", UserName = "******" }; _repository.Save(comment, true); var res = CommentService.Instance(_repository).GetByGroup("eternity"); Assert.IsNotNull(res); Assert.AreEqual(true,res.Any()); _repository.Delete(comment); }
public void Save(Comment comment) { this._repository.Save(comment, true); }
public void DeleteComment(Comment comment) { this._repository.Delete(comment,true); }
public void Send(dynamic message, string groupName) { // Call the broadcastMessage method to update clients. message.date = DateTime.Now.ToString("F", CultureInfo.CreateSpecificCulture("en-US")); message.id = Guid.NewGuid().ToString(); Clients.Group(groupName).sendMessage(message); if (HttpContext.Current.Cache[groupName] == null) { var now = DateTime.Now; var lst = new List<dynamic>(); lst.Add(message); HttpContext.Current.Cache.Add(groupName, lst, null, DateTime.MaxValue, new TimeSpan(0, 0, 0, 30), CacheItemPriority.Default, (key, value, reason) => CacheCallBack(key)); } else { var currentComment = new Comment { CommentId = Guid.Parse((string)message.id), GroupName = groupName, CommentText = message.message, UserName = message.name, AddedDate = DateTime.ParseExact((string)message.date, "F", CultureInfo.CreateSpecificCulture("en-US")) }; var helper = new IocHelper(); helper.CommentService.Save(currentComment); (HttpContext.Current.Cache[groupName] as List<dynamic>).Add(message); } }