Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public void Save(Comment comment)
 {
     this._repository.Save(comment, true);
 }
Exemplo n.º 3
0
 public void DeleteComment(Comment comment)
 {
     this._repository.Delete(comment,true);
 }
Exemplo n.º 4
0
        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);
            }
        }