public EventObjectAll eventsFollowing(int userId, Int64 eventId) { EventObjectAll allObjects = new EventObjectAll(); if (eventId == 0) { eventId = 99999999; } Classes.UserInfo ui = new Classes.UserInfo(); int locationId = ui.locationIdByUserId(userId); DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_followingEvents", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; sda.SelectCommand.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; //try //{ sda.Fill(ds); dt = ds.Tables[0]; //} //catch (Exception ex) //{ //} //finally //{ sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); //} if (dt.Rows.Count == 0) { return(allObjects); } else { Classes.Date d = new Classes.Date(); Classes.Nearby n = new Classes.Nearby(); EventObject object1 = new EventObject(); EventObject object2 = new EventObject(); EventObject object3 = new EventObject(); EventObject object4 = new EventObject(); EventObject object5 = new EventObject(); for (int i = 0; i < dt.Rows.Count; i++) { string Location = ""; Classes.Locations l = new Classes.Locations(); DataTable dtLocation = l.getLocationInfoByCityId(Convert.ToInt32(dt.Rows[i]["LocationId"].ToString())); if (dtLocation.Rows.Count == 0) { Location = "Not Available!"; } else { Location = dtLocation.Rows[0]["CountryName"].ToString() + " - " + dtLocation.Rows[0]["CityName"].ToString(); } // Show profile's photo string profilePicUrl; if (Convert.ToBoolean(dt.Rows[i]["HasPhoto"].ToString())) { profilePicUrl = "Files/ProfilesPhotos/" + dt.Rows[i]["OwnerId"].ToString() + "-100.jpg"; } else { profilePicUrl = "Images/nophoto.png"; } // Rate int rate = 0; int rateSufficient = Convert.ToInt32(ConfigurationManager.AppSettings["RateSufficient"].ToString()); int rateCount = Convert.ToInt32(dt.Rows[i]["rateCount"].ToString()); int rateScore = Convert.ToInt32(dt.Rows[i]["rateScore"].ToString()); if (rateCount >= rateSufficient) { rate = (20 * rateScore) / rateCount; } EventObject myEventObject = new EventObject( Convert.ToInt64(dt.Rows[i]["EventId"].ToString()), dt.Rows[i]["Name"].ToString(), d.FormatRemainedDate(dt.Rows[i]["Date"].ToString()), Convert.ToInt16(dt.Rows[i]["TypeId"].ToString()), Convert.ToInt16(dt.Rows[i]["CoverId"].ToString()), Convert.ToInt32(dt.Rows[i]["OwnerId"].ToString()), Location, rate, dt.Rows[i]["OwnerName"].ToString(), Convert.ToInt32(dt.Rows[i]["Participants"].ToString() + 1), Convert.ToInt32(dt.Rows[i]["ParticipantsAccepted"].ToString() + 1), profilePicUrl); switch (i) { case 0: { object1 = myEventObject; break; } case 1: { object2 = myEventObject; break; } case 2: { object3 = myEventObject; break; } case 3: { object4 = myEventObject; break; } case 4: { object5 = myEventObject; break; } } allObjects = new EventObjectAll( object1, object2, object3, object4, object5); } return(allObjects); } }
public Tuple<int, DataTable> profileInfo(int userId, string profileId) { int status = 0; DataTable dt = new DataTable(); DataTable dt2 = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_getProfileInfoByUsername", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@Username", SqlDbType.VarChar).Value = profileId; //check if query string is user id or username double num; if (double.TryParse(profileId, out num)) { sda = new SqlDataAdapter("sp_getProfileInfoByUserId", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(profileId); } //try //{ sda.Fill(ds); dt = ds.Tables[0]; //} //catch (Exception ex) //{ //} //finally //{ sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); //} if (dt.Rows.Count == 0)// Profile doesn't exist { status = -1; } else { // Profile is redistrected if (Convert.ToInt32(dt.Rows[0]["Status"].ToString()) != 1) { status = -2; } else { status = 1; // generate the info DataRow dr2 = null; //define the columns dt2.Columns.Add(new DataColumn("ProfilePicUrl", typeof(string))); dt2.Columns.Add(new DataColumn("isOwner", typeof(string))); dt2.Columns.Add(new DataColumn("isFollower", typeof(string))); dt2.Columns.Add(new DataColumn("FirstName", typeof(string))); dt2.Columns.Add(new DataColumn("LastName", typeof(string))); dt2.Columns.Add(new DataColumn("Username", typeof(string))); dt2.Columns.Add(new DataColumn("FollowersCount", typeof(string))); dt2.Columns.Add(new DataColumn("FollowingCount", typeof(string))); dt2.Columns.Add(new DataColumn("About", typeof(string))); dt2.Columns.Add(new DataColumn("UserId", typeof(string))); dt2.Columns.Add(new DataColumn("ProfileVerified", typeof(string))); dt2.Columns.Add(new DataColumn("RateCount", typeof(string))); dt2.Columns.Add(new DataColumn("RatePercent", typeof(string))); dt2.Columns.Add(new DataColumn("CountryCode", typeof(string))); dt2.Columns.Add(new DataColumn("CountryName", typeof(string))); dt2.Columns.Add(new DataColumn("CityName", typeof(string))); dt2.Columns.Add(new DataColumn("CoverUrl", typeof(string))); //create new row dr2 = dt2.NewRow(); //add values to each rows if (userId.ToString() == dt.Rows[0]["UserId"].ToString()) //user is the profile owner { dr2["isOwner"] = "true"; } else { dr2["isOwner"] = "false"; } // is visitor follower bool isFollower = false; if (userId != 0) { isFollower = isUserFollower(Convert.ToInt32(dt.Rows[0]["UserId"].ToString()), userId); } if (isFollower) { dr2["isFollower"] = "true"; } else { dr2["isFollower"] = "false"; } // Profile info dr2["FirstName"] = dt.Rows[0]["FirstName"].ToString(); dr2["LastName"] = dt.Rows[0]["LastName"].ToString(); dr2["Username"] = dt.Rows[0]["Username"].ToString(); dr2["FollowersCount"] = dt.Rows[0]["FollowersCount"].ToString(); dr2["FollowingCount"] = dt.Rows[0]["FollowingCount"].ToString(); dr2["About"] = dt.Rows[0]["About"].ToString(); dr2["UserId"] = dt.Rows[0]["UserId"].ToString(); dr2["ProfileVerified"] = dt.Rows[0]["ProfileVerified"].ToString(); dr2["RateCount"] = dt.Rows[0]["RateCount"].ToString(); dr2["CoverUrl"] = "Images/Covers/" + dt.Rows[0]["CoverId"].ToString() + ".jpg"; Classes.Locations l = new Classes.Locations(); DataTable dtLocation = l.getLocationInfoByCityId(Convert.ToInt32(dt.Rows[0]["LocationId"].ToString())); if (dtLocation.Rows.Count == 0) { } else { dr2["CountryCode"] = dtLocation.Rows[0]["CountryCode"].ToString(); dr2["CountryName"] = dtLocation.Rows[0]["CountryName"].ToString(); dr2["CityName"] = dtLocation.Rows[0]["CityName"].ToString(); } // Rate int rateSufficient = Convert.ToInt32(ConfigurationManager.AppSettings["RateSufficient"].ToString()); int rateCount = Convert.ToInt32(dt.Rows[0]["rateCount"].ToString()); int rateScore = Convert.ToInt32(dt.Rows[0]["rateScore"].ToString()); if (rateCount >= rateSufficient) { int popularity = (20 * rateScore) / rateCount; dr2["RatePercent"] = popularity.ToString(); } else { dr2["RatePercent"] = "NA"; } // Show profile's photo if (Convert.ToBoolean(dt.Rows[0]["HasPhoto"].ToString())) { dr2["ProfilePicUrl"] = "Files/ProfilesPhotos/" + dt.Rows[0]["UserId"].ToString() + "-100.jpg"; } else { dr2["ProfilePicUrl"] = "Images/nophoto.png"; } //add the row to DataTable dt2.Rows.Add(dr2); } } return new Tuple<int, DataTable>(status, dt2); }
public EventObjectAll eventsCity(int userId, Int64 eventId, int mode) { EventObjectAll allObjects = new EventObjectAll(); string spName = ""; int days = 0; if (eventId == 0) { eventId = 99999999; } if (mode == 1) { spName = "sp_nearbyCityAll"; } else if (mode == 2)//day { spName = "sp_nearbyCityDate"; days = 1; } else if (mode == 3)//week { spName = "sp_nearbyCityDate"; days = 7; } else if (mode == 4)//month { spName = "sp_nearbyCityDate"; days = 31; } Classes.UserInfo ui = new Classes.UserInfo(); int locationId = ui.locationIdByUserId(userId); DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter(spName, sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@LocationId", SqlDbType.Int).Value = locationId; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; sda.SelectCommand.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sda.SelectCommand.Parameters.Add("@Days", SqlDbType.SmallInt).Value = days; //try //{ sda.Fill(ds); dt = ds.Tables[0]; //} //catch (Exception ex) //{ //} //finally //{ sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); //} if (dt.Rows.Count == 0) { return allObjects; } else { Classes.Date d = new Classes.Date(); Classes.Nearby n = new Classes.Nearby(); EventObject object1 = new EventObject(); EventObject object2 = new EventObject(); EventObject object3 = new EventObject(); EventObject object4 = new EventObject(); EventObject object5 = new EventObject(); string Location = ""; Classes.Locations l = new Classes.Locations(); DataTable dtLocation = l.getLocationInfoByCityId(Convert.ToInt32(locationId)); if (dtLocation.Rows.Count == 0) { Location = "Not Available!"; } else { Location = dtLocation.Rows[0]["CountryName"].ToString() + " - " + dtLocation.Rows[0]["CityName"].ToString(); } for (int i = 0; i < dt.Rows.Count; i++) { // Show profile's photo string profilePicUrl; if (Convert.ToBoolean(dt.Rows[i]["HasPhoto"].ToString())) { profilePicUrl = "Files/ProfilesPhotos/" + dt.Rows[i]["OwnerId"].ToString() + "-100.jpg"; } else { profilePicUrl = "Images/nophoto.png"; } // Rate int rate = 0; int rateSufficient = Convert.ToInt32(ConfigurationManager.AppSettings["RateSufficient"].ToString()); int rateCount = Convert.ToInt32(dt.Rows[i]["rateCount"].ToString()); int rateScore = Convert.ToInt32(dt.Rows[i]["rateScore"].ToString()); if (rateCount >= rateSufficient) { rate = (20 * rateScore) / rateCount; } EventObject myEventObject = new EventObject( Convert.ToInt64(dt.Rows[i]["EventId"].ToString()), dt.Rows[i]["Name"].ToString(), d.FormatRemainedDate(dt.Rows[i]["Date"].ToString()), Convert.ToInt16(dt.Rows[i]["TypeId"].ToString()), Convert.ToInt16(dt.Rows[i]["CoverId"].ToString()), Convert.ToInt32(dt.Rows[i]["OwnerId"].ToString()), Location, rate, dt.Rows[i]["OwnerName"].ToString(), Convert.ToInt32(dt.Rows[i]["Participants"].ToString() + 1), Convert.ToInt32(dt.Rows[i]["ParticipantsAccepted"].ToString() + 1), profilePicUrl); switch (i) { case 0: { object1 = myEventObject; break; } case 1: { object2 = myEventObject; break; } case 2: { object3 = myEventObject; break; } case 3: { object4 = myEventObject; break; } case 4: { object5 = myEventObject; break; } } } allObjects = new EventObjectAll( object1, object2, object3, object4, object5); return allObjects; } }
public Tuple <int, DataTable> profileInfo(int userId, string profileId) { int status = 0; DataTable dt = new DataTable(); DataTable dt2 = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_getProfileInfoByUsername", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@Username", SqlDbType.VarChar).Value = profileId; //check if query string is user id or username double num; if (double.TryParse(profileId, out num)) { sda = new SqlDataAdapter("sp_getProfileInfoByUserId", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(profileId); } //try //{ sda.Fill(ds); dt = ds.Tables[0]; //} //catch (Exception ex) //{ //} //finally //{ sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); //} if (dt.Rows.Count == 0)// Profile doesn't exist { status = -1; } else { // Profile is redistrected if (Convert.ToInt32(dt.Rows[0]["Status"].ToString()) != 1) { status = -2; } else { status = 1; // generate the info DataRow dr2 = null; //define the columns dt2.Columns.Add(new DataColumn("ProfilePicUrl", typeof(string))); dt2.Columns.Add(new DataColumn("isOwner", typeof(string))); dt2.Columns.Add(new DataColumn("isFollower", typeof(string))); dt2.Columns.Add(new DataColumn("FirstName", typeof(string))); dt2.Columns.Add(new DataColumn("LastName", typeof(string))); dt2.Columns.Add(new DataColumn("Username", typeof(string))); dt2.Columns.Add(new DataColumn("FollowersCount", typeof(string))); dt2.Columns.Add(new DataColumn("FollowingCount", typeof(string))); dt2.Columns.Add(new DataColumn("About", typeof(string))); dt2.Columns.Add(new DataColumn("UserId", typeof(string))); dt2.Columns.Add(new DataColumn("ProfileVerified", typeof(string))); dt2.Columns.Add(new DataColumn("RateCount", typeof(string))); dt2.Columns.Add(new DataColumn("RatePercent", typeof(string))); dt2.Columns.Add(new DataColumn("CountryCode", typeof(string))); dt2.Columns.Add(new DataColumn("CountryName", typeof(string))); dt2.Columns.Add(new DataColumn("CityName", typeof(string))); dt2.Columns.Add(new DataColumn("CoverUrl", typeof(string))); //create new row dr2 = dt2.NewRow(); //add values to each rows if (userId.ToString() == dt.Rows[0]["UserId"].ToString()) //user is the profile owner { dr2["isOwner"] = "true"; } else { dr2["isOwner"] = "false"; } // is visitor follower bool isFollower = false; if (userId != 0) { isFollower = isUserFollower(Convert.ToInt32(dt.Rows[0]["UserId"].ToString()), userId); } if (isFollower) { dr2["isFollower"] = "true"; } else { dr2["isFollower"] = "false"; } // Profile info dr2["FirstName"] = dt.Rows[0]["FirstName"].ToString(); dr2["LastName"] = dt.Rows[0]["LastName"].ToString(); dr2["Username"] = dt.Rows[0]["Username"].ToString(); dr2["FollowersCount"] = dt.Rows[0]["FollowersCount"].ToString(); dr2["FollowingCount"] = dt.Rows[0]["FollowingCount"].ToString(); dr2["About"] = dt.Rows[0]["About"].ToString(); dr2["UserId"] = dt.Rows[0]["UserId"].ToString(); dr2["ProfileVerified"] = dt.Rows[0]["ProfileVerified"].ToString(); dr2["RateCount"] = dt.Rows[0]["RateCount"].ToString(); dr2["CoverUrl"] = "Images/Covers/" + dt.Rows[0]["CoverId"].ToString() + ".jpg"; Classes.Locations l = new Classes.Locations(); DataTable dtLocation = l.getLocationInfoByCityId(Convert.ToInt32(dt.Rows[0]["LocationId"].ToString())); if (dtLocation.Rows.Count == 0) { } else { dr2["CountryCode"] = dtLocation.Rows[0]["CountryCode"].ToString(); dr2["CountryName"] = dtLocation.Rows[0]["CountryName"].ToString(); dr2["CityName"] = dtLocation.Rows[0]["CityName"].ToString(); } // Rate int rateSufficient = Convert.ToInt32(ConfigurationManager.AppSettings["RateSufficient"].ToString()); int rateCount = Convert.ToInt32(dt.Rows[0]["rateCount"].ToString()); int rateScore = Convert.ToInt32(dt.Rows[0]["rateScore"].ToString()); if (rateCount >= rateSufficient) { int popularity = (20 * rateScore) / rateCount; dr2["RatePercent"] = popularity.ToString(); } else { dr2["RatePercent"] = "NA"; } // Show profile's photo if (Convert.ToBoolean(dt.Rows[0]["HasPhoto"].ToString())) { dr2["ProfilePicUrl"] = "Files/ProfilesPhotos/" + dt.Rows[0]["UserId"].ToString() + "-100.jpg"; } else { dr2["ProfilePicUrl"] = "Images/nophoto.png"; } //add the row to DataTable dt2.Rows.Add(dr2); } } return(new Tuple <int, DataTable>(status, dt2)); }
public string notificationText(int NotificationType, Int64 itemId) { switch (NotificationType) { case 1: { return("Congratulations! You have successfully registered!"); break; } case 2: { Classes.Events e = new Classes.Events(); string eventName = e.getEventNameByEventId(itemId); return("Guess what?! You have been accepted to participate in this event: " + eventName); break; } case 3: { Classes.Events e = new Classes.Events(); string eventName = e.getEventNameByEventId(itemId); return("Your event, " + eventName + " is full now!"); break; } case 4: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return(userFullName + " started following you."); break; } case 5: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return(userFullName + " registered in the app with your invitation."); break; } case 6: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return(userFullName + " just reviewed you!"); break; } case 7: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return(userFullName + " canceled participation in your event."); break; } case 8: { Classes.Events e = new Classes.Events(); string eventName = e.getEventNameByEventId(itemId); return("You just got removed from " + eventName + "."); break; } case 9: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return(userFullName + " removed an event that you were a participant in it."); break; } case 10: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return(userFullName + " is waiting for your review."); break; } case 11: { return("You have successfully verified your email address."); break; } case 12: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return(userFullName + " from your Facebook friends just became a CityCrowder."); break; } case 13: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return(userFullName + " became a CityCrowder with your invitation."); break; } case 14: { Classes.Locations l = new Classes.Locations(); string locationName = l.getLocationInfoById(Convert.ToInt32(itemId)); return("Good news! The location you requested to be added is now available! Locaion: " + locationName); break; } default: { return(""); break; } } }
public string notificationText(int NotificationType, Int64 itemId) { switch (NotificationType) { case 1: { return "Congratulations! You have successfully registered!"; break; } case 2: { Classes.Events e = new Classes.Events(); string eventName = e.getEventNameByEventId(itemId); return "Guess what?! You have been accepted to participate in this event: " + eventName; break; } case 3: { Classes.Events e = new Classes.Events(); string eventName = e.getEventNameByEventId(itemId); return "Your event, " + eventName + " is full now!"; break; } case 4: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return userFullName + " started following you."; break; } case 5: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return userFullName + " registered in the app with your invitation."; break; } case 6: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return userFullName + " just reviewed you!"; break; } case 7: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return userFullName + " canceled participation in your event."; break; } case 8: { Classes.Events e = new Classes.Events(); string eventName = e.getEventNameByEventId(itemId); return "You just got removed from " + eventName + "."; break; } case 9: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return userFullName + " removed an event that you were a participant in it."; break; } case 10: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return userFullName + " is waiting for your review."; break; } case 11: { return "You have successfully verified your email address."; break; } case 12: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return userFullName + " from your Facebook friends just became a CityCrowder."; break; } case 13: { Classes.UserInfo ui = new Classes.UserInfo(); string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId)); return userFullName + " became a CityCrowder with your invitation."; break; } case 14: { Classes.Locations l = new Classes.Locations(); string locationName = l.getLocationInfoById(Convert.ToInt32(itemId)); return "Good news! The location you requested to be added is now available! Locaion: " + locationName; break; } default: { return ""; break; } } }