public void DisLike(string msgid)
 {
     int msgId = Convert.ToInt32(msgid);
     Message message = db.Message.First(i => i.MessageId == msgId);
     message.Disliked += 1;
     db.SaveChanges();
     FeedContent messages = new FeedContent();
     messages.MessageId = message.MessageId;
     messages.DateMessaged = message.DateMessaged;
     messages.UserName = message.User.UserName;
     messages.MessageDesc = message.MessageDesc;
     messages.UserId = message.UserId;
     messages.liked = message.LikedCount;
     messages.disliked = message.Disliked;
     var myhubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub1>();
     myhubContext.Clients.All.NewDislike(messages);
 }
        public void SaveMessage(string msg)
        {
            Message message = new Message();
            message.MessageDesc = msg;
            HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
            string UserName = authCookie["userName"].ToString();

            UserModel matchUser = new UserModel(UserName);
            message.UserId = matchUser.UserId;
            message.DateMessaged = DateTime.UtcNow;
            db.Message.Add(message);
            db.SaveChanges();
            FeedContent messages = new FeedContent();
            messages.DateMessaged = message.DateMessaged;
            messages.UserName = matchUser.UserName;
            messages.MessageDesc = message.MessageDesc;
            messages.UserId = message.UserId;
            messages.MessageId = message.MessageId;
            messages.liked = message.LikedCount;
            messages.disliked = message.Disliked;
            List<CommentContent> commentContent = new List<CommentContent>();
            messages.Comments = new List<CommentContent>();
            var myhubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub1>();
            myhubContext.Clients.All.NewMessage(messages);
        }
Exemple #3
0
 public void NewMessage(FeedContent msg)
 {
     Clients.All.NewMessage("Hello message to all clients");
 }