Пример #1
0
        /// <summary>
        /// Reads the message.
        /// </summary>
        /// <param name="objId">The object identifier.</param>
        /// <param name="userId">The user identifier.</param>
        /// <returns></returns>
        public static bool ReadMessage(string objId, Guid userId)
        {
            var model = new Messages
            {
                Status     = (int)MessageStatus.HasRead,
                UpdateTime = DateTime.Now
            };
            var result = MongoDBHelper.UpdateMany(x => x._id == new ObjectId(objId) && x.UserId == userId.ToString(), model, new List <string> {
                "Status", "UpdateTime"
            });

            return(result > 0);
        }
Пример #2
0
        /// <summary>
        /// Onekey Reads the message.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns></returns>
        public static bool OnekeyReadMessage(Guid userId)
        {
            var model = new Messages
            {
                Status     = (int)MessageStatus.HasRead,
                UpdateTime = DateTime.Now
            };
            var result = MongoDBHelper.UpdateMany(x => x.UserId == userId.ToString() && x.Status == (int)MessageStatus.Normal, model, new List <string> {
                "Status", "UpdateTime"
            });

            return(result > 0);
        }
Пример #3
0
        /// <summary>
        /// Adds the message.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="userType">Type of the user.</param>
        /// <param name="queryId">The query identifier.</param>
        /// <param name="msgType">Type of the MSG.</param>
        /// <param name="titleKey">The title key.</param>
        /// <param name="subTitleKey">The sub title key.</param>
        /// <param name="coinCode">The coin code.</param>
        /// <param name="title">The title.</param>
        /// <param name="body">The body.</param>
        /// <param name="noticeId"></param>
        /// <returns></returns>
        public static bool AddMessage(Guid userId, UserType userType, string queryId, int msgType, string titleKey, string subTitleKey, string coinCode, string title, string body, out string noticeId)
        {
            var flag     = ObjectId.GenerateNewId();
            var messages = new Messages
            {
                _id         = flag,
                UserId      = userId.ToString(),
                UserType    = (int)userType,
                QueryId     = queryId,
                MsgType     = msgType,
                TitleKey    = titleKey,
                SubTitleKey = subTitleKey,
                CoinCode    = coinCode,
                Title       = title,
                Body        = body,
                Status      = 0,

                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now
            };

            noticeId = flag.ToString();
            return(MongoDBHelper.AddSignleObject(messages));
        }