コード例 #1
0
        public ActionResult SendNotification(string title, string message, Guid user, NotificationType type)
        {
            var returnModel = new SendNotificationReturnModel
            {
                id      = Guid.NewGuid(),
                idUser  = user,
                title   = title,
                message = message,
                type    = type
            };

            if (UserHandler.ConnectedIds.Contains(returnModel.idUser.ToString()))
            {
                _context.Clients.Client(returnModel.idUser.ToString())
                .notificationReceived(
                    returnModel.id,
                    returnModel.title,
                    returnModel.message,
                    returnModel.type);
            }
            else
            {
                returnModel.ErrorMessage = "User is not connected anymore";
            }

            return(new JsonResult
            {
                Data = returnModel
            });
        }
コード例 #2
0
        public SendNotificationReturnModel SendNotification(string title, string message, Guid user, NotificationType type)
        {
            var retorno = new SendNotificationReturnModel
            {
                id      = Guid.NewGuid(),
                title   = title,
                message = message,
                type    = type,
                idUser  = user
            };

            if (UserHandler.ConnectedIds.Contains(user.ToString()))
            {
                Clients.Client(retorno.idUser.ToString())
                .notificationReceived(
                    retorno.id,
                    retorno.title,
                    retorno.message,
                    retorno.type);

                return(retorno);
            }
            else
            {
                retorno.ErrorMessage = "User is not connected";

                return(retorno);
            }
        }