Пример #1
0
 public List<BsonDocument> GetUsers(int limit, int skip)
 {
     DatingBookDataProvider dbDataProvider = new DatingBookDataProvider();
     var users = dbDataProvider.Paging(limit, skip, "first_name", "last_name", "gender", "last_visit");
     ActivityDataProvider activity = new ActivityDataProvider();
     foreach (var user in users)
     {
         user["num_of_visits"] = activity.GetProfileViewersCount(user["_id"].AsObjectId);
     }
     return users;
 }
Пример #2
0
 public dynamic GetUserInfo(ObjectId userId)
 {
     BsonDocument output = null;
     DatingBookDataProvider dbProvider = new DatingBookDataProvider();
     FacebookDataProvider fbProvider = new FacebookDataProvider();
     var datingBookUser = dbProvider.GetDatingBookUser(userId,
         "birthday",
         "fbid",
         "facebook_user_id",
         "fname",
         "lname",
         "last_visit",
         "is_deleted",
         "gender",
         "email",
         "picture",
         "spam_reporters",
         "set_popup");
     if (datingBookUser != null)
     {
         var fbUser = fbProvider.GetFacebookBookUser(datingBookUser["facebook_user_id"].AsObjectId, "is_active",
             "link",
             "is_banned",
             "is_post_on_wall",
             "deauthorized_date",
             "date_created");
         output = fbUser.Merge(datingBookUser);
         output["registration_date"]  = output["date_created"];
         output.Remove("date_created");
         output["age"] = (int)((DateTime.UtcNow - output["birthday"].AsDateTime).TotalDays / 365);
         output.Remove("birthday");
         ActivityDataProvider activity = new ActivityDataProvider();
         output["visit_count"] = activity.GetVisitCountTotal(userId);
         output["num_of_visits"] = activity.GetUserTotalMessagesSent(userId);
         output["profile_viewers"] = activity.GetProfileViewersCount(userId);
         output["profile_viewes"] = activity.GetCountOfProfileViews(userId);
         output["num_liked"] = activity.GetLikedCount(userId);
         output["num_likers"] = activity.GetLikersCount(userId);
         output["num_favorited"] = activity.GetFavoritedCount(userId);
         output["num_favorites"] = activity.GetFavoritesCount(userId);
     }
     return output;
 }
Пример #3
0
        public dynamic GetDeauthorizedUsers(ViewByTime timeBack, int limit, int skip)
        {
            ActivityDataProvider prov = new ActivityDataProvider();
            long count;
            var deauthorizers = prov.GetDeauthorized(GetTimeBack(timeBack), limit, skip, out count);
            var activesUsers = new List<BsonDocument>();
            DateTime now = DateTime.UtcNow;

            foreach (var deatuhorized in deauthorizers)
            {
                //handle when unknown deatuhorized date
                deatuhorized["deauthorized_date"] = deatuhorized["date_modified"];
                //signup["_id"] = signup["_id"].ToString();
                deatuhorized.Add("age", (int)((now - deatuhorized["birthday"].AsDateTime).TotalDays / 365));
                deatuhorized.Remove("birthday");
            }
            return new
            {
                items = deauthorizers,
                total = count
            };
        }
Пример #4
0
 public dynamic GetMostActive(ViewByTime timeBack, int limit, int skip)
 {
     ActivityDataProvider prov = new ActivityDataProvider();
     long count;
     var actives = prov.GetMostActive(GetTimeBack(timeBack), limit,skip,  out count);
     var activesUsers = new List<BsonDocument>();
     DatingBookDataProvider datingDal = new DatingBookDataProvider();
     foreach (var active in actives)
     {
         var bsonDoc = datingDal.GetDatingBookUser(active["Key"].AsObjectId, "fname", "lname", "fbid", "gender", "birthday", "last_visit");
         if (bsonDoc != null)
         {
             //bsonDoc["_id"] = bsonDoc["_id"].ToString();
             bsonDoc = GetUserForDisplay(bsonDoc);
             bsonDoc.Add("visits_count", active["Value"]);
             activesUsers.Add(bsonDoc);
         }
     }
     return new
     {
         items = activesUsers,
         total = count
     };
 }
Пример #5
0
 public dynamic GetRecentMessageSessions(ViewByTime timeBack, int limit, int skip)
 {
     ActivityDataProvider prov = new ActivityDataProvider();
     long count;
     var messageSessions = prov.GetMessageSessions(GetTimeBack(timeBack), limit, skip, out count);
     DateTime now = DateTime.UtcNow;
     DatingBookDataProvider datingDal = new DatingBookDataProvider();
     foreach (var session in messageSessions)
     {
         var user1 = datingDal.GetDatingBookUser(session["user_1"].AsObjectId, "fname", "lname", "fbid", "gender", "birthday", "last_visit");
         user1 = GetUserForDisplay(user1);
         var user2 = datingDal.GetDatingBookUser(session["user_2"].AsObjectId, "fname", "lname", "fbid", "gender", "birthday", "last_visit");
         user2 = GetUserForDisplay(user2);
         session["user_1"] = user1;
         session["user_2"] = user2;
         session["messages_count"] = session["messages"].AsBsonArray.Count;
         session.Remove("messages");
     }
     return new
     {
         items = messageSessions,
         total = count
     };
 }
Пример #6
0
 public dynamic GetSignUps(ViewByTime timeBack, int limit, int skip)
 {
     ActivityDataProvider prov = new ActivityDataProvider();
     long count;
     var signUps = prov.GetSignUps(GetTimeBack(timeBack), limit,skip, out count);
     DateTime now = DateTime.UtcNow;
     foreach (var signup in signUps)
     {
         //signup["_id"] = signup["_id"].ToString();
         signup.Add("age", (int)((now - signup["birthday"].AsDateTime).TotalDays / 365));
         signup.Remove("birthday");
     }
     return new
     {
         items = signUps,
         total = count
     };
 }
Пример #7
0
 public dynamic GetSessionDetails(ObjectId objectId)
 {
     ActivityDataProvider prov = new ActivityDataProvider();
     DatingBookDataProvider datingDal = new DatingBookDataProvider();
     BsonDocument session = prov.GetMessagesSession(objectId);
     var user1 = datingDal.GetDatingBookUser(session["user_1"].AsObjectId, "fname", "lname", "fbid", "gender", "birthday", "last_visit");
     user1 = GetUserForDisplay(user1);
     var user2 = datingDal.GetDatingBookUser(session["user_2"].AsObjectId, "fname", "lname", "fbid", "gender", "birthday", "last_visit");
     user2 = GetUserForDisplay(user2);
     session["user_1"] = user1;
     session["user_2"] = user2;
     return session;
 }