Пример #1
0
        public void PostNotification(NotificationsBindingModel m)
        {
            if (!this.ModelState.IsValid)
            {
                return;
            }

            var notification = new Notification
            {
                SenderId   = m.SenderId,
                ReceiverId = m.ReceiverId,
                Content    = m.Content,
                PostedOn   = DateTime.Now
            };

            this.Data.Notifications.Add(notification);

            this.Data.SaveChanges();

            var receiverName = this.Data.Users.FirstOrDefault(u => u.Id == m.ReceiverId).UserName;

            var hub = new NotificationsHub();

            hub.GetNotifications(receiverName);
        }