Exemplo n.º 1
0
        public DatingBookUserInfo GetDatingBookUserInfo(string appName, ObjectId userId)
        {
            var datingBookUserInfo = _userDataProvider.GetDatingBookUserInfoByFacebookId(appName, userId);

            if (datingBookUserInfo == null)
                return null;

            if (!CheckIfUserPictureExist(appName, datingBookUserInfo))
                DownloadUserPicture(appName, datingBookUserInfo);

            datingBookUserInfo.LastVisit = DateTime.Now;
            ObjectId visitId = ObjectId.Empty;
            var whiteList = _userDataProvider.GetUsersWhitelist(appName);

            if (!whiteList.Exists((usr) => usr == datingBookUserInfo.FacebookId))
            {
                BsonDocument visit = new BsonDocument();
                visit.Add("dating_book_id", datingBookUserInfo.ObjectId);
                visit.Add("entered_at", datingBookUserInfo.LastVisit);
                visitId = _userDataProvider.InsertVisit(appName, visit);
            }

            datingBookUserInfo = _userDataProvider.UpdateDatingBookLastVisit(appName, datingBookUserInfo, visitId);

            var userEventInfo = new UserEventInfo
            {
                UserId = datingBookUserInfo.ObjectId,
                EventType = 1,
                DateCreated = DateTime.Now
            };

            _userDataProvider.InsertUserEvent(appName, userEventInfo);

            return datingBookUserInfo;
        }
Exemplo n.º 2
0
        public DatingBookUserInfo UpsertDatingBookUserInfo(string appName, ObjectId userId, DatingBookUserInfo datingBookUserInfo)
        {
            datingBookUserInfo = _userDataProvider.UpsertDatingbookUserInfo(appName, userId, datingBookUserInfo);

            if (datingBookUserInfo.IsNew)
            {
                if (!CheckIfUserPictureExist(appName, datingBookUserInfo))
                    DownloadUserPicture(appName, datingBookUserInfo);

                var userEventInfo = new UserEventInfo
                {
                    UserId = datingBookUserInfo.ObjectId,
                    EventType = 0,
                    DateCreated = DateTime.Now
                };

                _userDataProvider.InsertUserEvent(appName, userEventInfo);

                datingBookUserInfo.IsNew = false;
            }

            datingBookUserInfo.LastVisit = DateTime.Now;
            datingBookUserInfo = _userDataProvider.UpdateDatingBookLastVisit(appName, datingBookUserInfo);

            return datingBookUserInfo;
        }
Exemplo n.º 3
0
        public void AddVistor(string appName, ObjectId userId, string toUserId, string like, long appId)
        {
            var toUserIdObj = new ObjectId(toUserId);

            if (userId == toUserIdObj)
                return;

            if (like == "like")
            {
                var userLikeInfo = new UserLikeInfo
                {
                    UserId = userId,
                    ToUserId = toUserIdObj,
                    DateCreated = DateTime.Now
                };

                _userLikesDataProvider.InsertUserLike(appName, userLikeInfo);

                var userEventInfo = new UserEventInfo
                {
                    UserId = toUserIdObj,
                    EventType = 2,
                    DateCreated = DateTime.Now
                };

                _userDataProvider.InsertUserEvent(appName, userEventInfo);
            }
            else
            {
                var userVisitInfo = new UserVisitInfo
                {
                    UserId = userId,
                    ToUserId = toUserIdObj,
                    DateCreated = DateTime.Now,
                    DateModified = DateTime.Now
                };

                _userVisitsDataProvider.UpsertUserVisit(appName, userVisitInfo);
                _userVisitsDataProvider.SetUserVisit(appName, toUserIdObj);

                var fromUserInfo = _userDataProvider.GetDatingBookUserInfo(appName, userId);
                var toUserInfo = _userDataProvider.GetDatingBookUserInfo(appName, toUserIdObj);
                var appInfo = _appsDataProvider.GetAppInfo(appId);

                string msg = string.Format("{0} has watched your profile !", fromUserInfo.FirstName);

                _facebookDataProvider.SendFacebookAppNotification(toUserInfo.FacebookId, msg, msg, appInfo.AppAccessToken);
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public DatingBookUserInfo GetDatingBookUserInfo(string appName, ObjectId userId)
        {
            var datingBookUserInfo = _userDataProvider.GetDatingBookUserInfoByFacebookId(appName, userId);

            if (datingBookUserInfo == null)
                return null;

            if (!CheckIfUserPictureExist(appName, datingBookUserInfo))
                DownloadUserPicture(appName, datingBookUserInfo);

            datingBookUserInfo.LastVisit = DateTime.Now;
            datingBookUserInfo = _userDataProvider.UpdateDatingBookLastVisit(appName, datingBookUserInfo);

            var userEventInfo = new UserEventInfo
            {
                UserId = datingBookUserInfo.ObjectId,
                EventType = 1,
                DateCreated = DateTime.Now
            };

            _userDataProvider.InsertUserEvent(appName, userEventInfo);

            return datingBookUserInfo;
        }
Exemplo n.º 6
0
        public UserEventInfo InsertUserEvent(string appName, UserEventInfo userEventInfo)
        {
            var dataBase = _serverWrapper.ServerConnection.GetDatabase(appName);
            var collection = dataBase.GetCollection<UserEventInfo>(USER_EVENTS_COLLECTION_NAME);

            collection.EnsureIndex(new IndexKeysBuilder().Ascending("date_created"),
                IndexOptions.SetTimeToLive(new TimeSpan(30, 0, 0, 0)));

            collection.Insert(userEventInfo);

            return userEventInfo;
        }