コード例 #1
0
        public void DeleteFavorite(string appName, ObjectId userId, string toUserId)
        {
            var userFavoriteInfo = new UserFavoriteInfo();

            userFavoriteInfo.UserId = userId;
            userFavoriteInfo.ToUserId = new ObjectId(toUserId);
            userFavoriteInfo.IsActive = false;
            userFavoriteInfo.DateModified = DateTime.Now;

            _userFavoritesDataProvider.ResetUserFavorite(appName, userFavoriteInfo);
        }
コード例 #2
0
        public UserFavoriteInfo ResetUserFavorite(string appName, UserFavoriteInfo userFavoriteInfo)
        {
            var dataBase = _serverWrapper.ServerConnection.GetDatabase(appName);
            var collection = dataBase.GetCollection<UserFavoriteInfo>(USER_FAVORITES_COLLECTION_NAME);

            collection.EnsureIndex(new IndexKeysBuilder().Ascending("user_id", "to_user_id"), IndexOptions.SetUnique(true));

            var selectQuery = Query.And(Query.EQ("user_id", userFavoriteInfo.UserId),
                                        Query.EQ("to_user_id", userFavoriteInfo.ToUserId));

            var result = collection.FindOne(selectQuery);
            var updateQuery = new UpdateBuilder();

            updateQuery.Set("date_modified", userFavoriteInfo.DateModified);
            updateQuery.Set("is_active", userFavoriteInfo.IsActive);

            collection.Update(selectQuery, updateQuery);

            return userFavoriteInfo;
        }
コード例 #3
0
        public void AddFavorite(string appName, ObjectId userId, string toUserId)
        {
            var userFavoriteInfo = new UserFavoriteInfo();

            userFavoriteInfo.UserId = userId;
            userFavoriteInfo.ToUserId = new ObjectId(toUserId);
            userFavoriteInfo.IsActive = true;
            userFavoriteInfo.DateCreated = DateTime.Now;
            userFavoriteInfo.DateModified = DateTime.Now;

            _userFavoritesDataProvider.UpsertUserFavorite(appName, userFavoriteInfo);

            var userEventInfo = new UserEventInfo
            {
                UserId = new ObjectId(toUserId),
                EventType = 3,
                DateCreated = DateTime.Now
            };

            _userDataProvider.InsertUserEvent(appName, userEventInfo);
        }