protected void ButtonNotification_Click(object sender, EventArgs e) { int userId = Convert.ToInt32(TextBoxUserId.Text); int locationId = Convert.ToInt32(TextBoxLocationId.Text); Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(userId, 14, locationId); }
public int removeParticipant(int ownerId, int userId, Int64 eventId) { int status = 0; //0 user not owner 1 participants cancelled 2 user was not participant Classes.Events ev = new Classes.Events(); if (!ev.isUserOwner(ownerId, eventId)) { status = 0; } else { bool participantStatus = ev.isUserParticipant(userId, eventId); if (!participantStatus) { status = 2; } else { status = 1; SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventRemoveParticipant", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); } Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(userId, 8, eventId); } } return(status); }
public int eventDelete(Int64 eventId, int userId) { int status = 0; DataTable dtParticipants = eventParticipants(eventId); for (int i = 0; i < dtParticipants.Rows.Count; i++) { int participantId = Convert.ToInt32(dtParticipants.Rows[i]["UserId"].ToString()); if (userId == participantId) { continue; } Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(participantId, 9, userId); } SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventDelete", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; //try //{ sqlConn.Open(); sqlCmd.ExecuteNonQuery(); //} //catch //{ //} //finally //{ sqlConn.Close(); sqlConn.Dispose(); sqlCmd.Dispose(); //} status = 1; return(status); }
protected void GridViewRequests_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.CompareTo("RequestReject") == 0) { SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter("sp_profileRequestInfo", sqlConn); SqlCommand sqlCmd = new SqlCommand("sp_profileRequestsReject", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@ProfileRequestId", SqlDbType.Int).Value = Convert.ToInt32(e.CommandArgument.ToString()); sda.Fill(ds); dt = ds.Tables[0]; Classes.Notifications no = new Classes.Notifications(); no.addNotification(Convert.ToInt32(dt.Rows[0]["UserId"].ToString()), 3, dt.Rows[0]["ProfileName"].ToString(), DropDownListReason.SelectedValue.ToString()); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@ProfileRequestId", SqlDbType.Int).Value = Convert.ToInt32(e.CommandArgument.ToString()); sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(dt.Rows[0]["UserId"].ToString()); sqlConn.Open(); sqlCmd.ExecuteNonQuery(); GridViewRequests.DataBind(); } catch (Exception ex) { } finally { sqlCmd.Dispose(); sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); } } if (e.CommandName.CompareTo("RequestAccept") == 0) { SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter("sp_profileRequestInfo", sqlConn); SqlCommand sqlCmd = new SqlCommand("sp_profileRequestsAccept", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@ProfileRequestId", SqlDbType.Int).Value = Convert.ToInt32(e.CommandArgument.ToString()); sda.Fill(ds); dt = ds.Tables[0]; sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@ProfileRequestId", SqlDbType.Int).Value = Convert.ToInt32(e.CommandArgument.ToString()); sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(dt.Rows[0]["UserId"].ToString()); sqlCmd.Parameters.Add("@ProfileName", SqlDbType.NVarChar).Value = dt.Rows[0]["ProfileName"].ToString(); sqlCmd.Parameters.Add("@ProfileType", SqlDbType.Int).Value = Convert.ToInt32(dt.Rows[0]["ProfileType"].ToString()); sqlCmd.Parameters.Add("@ProfileCategoryId", SqlDbType.Int).Value = Convert.ToInt32(dt.Rows[0]["ProfileCategoryId"].ToString()); sqlConn.Open(); int ProfileId = (int)sqlCmd.ExecuteScalar(); Classes.Notifications no = new Classes.Notifications(); no.addNotification(Convert.ToInt32(dt.Rows[0]["UserId"].ToString()), 2, dt.Rows[0]["ProfileName"].ToString(), ProfileId.ToString()); GridViewRequests.DataBind(); } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sqlCmd.Dispose(); sqlConn.Dispose(); } } }
public int followAction(int userId, int profileId) { // is visitor follower int status = 0; DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_isUserFollower", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = profileId; sda.SelectCommand.Parameters.Add("@FollowerId", SqlDbType.Int).Value = userId; //try //{ sda.Fill(ds); dt = ds.Tables[0]; SqlCommand sqlCmd = new SqlCommand("sp_followUser", sqlConn); if (dt.Rows.Count == 0) { sqlCmd = new SqlCommand("sp_followUser", sqlConn); status = 1; // add notification Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(profileId, 4, Convert.ToInt64(userId)); } else { sqlCmd = new SqlCommand("sp_unfollowUser", sqlConn); status = 2; } //try //{ sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = profileId; sqlCmd.Parameters.Add("@FollowerId", SqlDbType.Int).Value = userId; sqlConn.Open(); sqlCmd.ExecuteNonQuery(); //} //catch //{ //} //finally //{ sqlConn.Close(); sqlConn.Dispose(); sqlCmd.Dispose(); //} //} //catch (Exception ex) //{ //} //finally //{ sqlConn.Close(); sda.Dispose(); //} return status; }
public Int16 completion(int userId, string username, string firstName, string lastName, Int16 gender, int locationId, string birthDate, bool hasPhoto) { Int16 status = 0; //check username valid Regex RgxUrl = new Regex("[^a-zA-Z]"); if (Regex.Matches(username, @"[a-zA-Z]").Count == 0) { status = -2; } else { //special symbols RgxUrl = new Regex("[^a-zA-Z0-9]"); if (RgxUrl.IsMatch(username)) { status = -3; } else { //check username exists Classes.UserInfo ui = new Classes.UserInfo(); bool usernameExists = ui.checkUsernameExists(username); if (usernameExists) { status = -1; } else { status = 1; SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_completion", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; sqlCmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = username; sqlCmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = firstName; sqlCmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = lastName; sqlCmd.Parameters.Add("@Gender", SqlDbType.TinyInt).Value = gender; sqlCmd.Parameters.Add("@LocationId", SqlDbType.Int).Value = locationId; sqlCmd.Parameters.Add("@BirthDate", SqlDbType.Date).Value = Convert.ToDateTime(birthDate);//Convert.ToDateTime(dob); sqlCmd.Parameters.Add("@HasPhoto", SqlDbType.Bit).Value = hasPhoto; //try //{ sqlConn.Open(); sqlCmd.ExecuteNonQuery(); //} //catch (Exception ex) //{ //} //finally //{ sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); //} Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(userId, 1, Convert.ToInt64(userId)); string email = ui.getEmailByUserId(userId); string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString(); string link = siteLink; string message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='" + link + "'>CLICK HERE</a> to visit the website.<br/><br/>CityCowd Team"; if (!ui.isUserEmailVerified(userId)) { string VCode = Convert.ToString(Guid.NewGuid()); SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd2 = new SqlCommand("sp_verifyEmailAdd", sqlConn2); sqlCmd2.CommandType = CommandType.StoredProcedure; sqlCmd2.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; sqlCmd2.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = VCode; sqlConn2.Open(); sqlCmd2.ExecuteNonQuery(); link = siteLink + "Verify/Email/" + VCode; message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='" + link + "'>CLICK HERE</a> to verify your email address and visit the website.<br/><br/>CityCowd Team"; } Classes.Mail m = new Classes.Mail(); int status2 = m.sendMail("register", email, "Hi, " + firstName + message, ""); } } } return(status); }
public Int16 completion(int userId, string username, string firstName, string lastName, Int16 gender, int locationId, string birthDate, bool hasPhoto) { Int16 status = 0; //check username valid Regex RgxUrl = new Regex("[^a-zA-Z]"); if (Regex.Matches(username, @"[a-zA-Z]").Count == 0) { status = -2; } else { //special symbols RgxUrl = new Regex("[^a-zA-Z0-9]"); if (RgxUrl.IsMatch(username)) { status = -3; } else { //check username exists Classes.UserInfo ui = new Classes.UserInfo(); bool usernameExists = ui.checkUsernameExists(username); if (usernameExists) { status = -1; } else { status = 1; SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_completion", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; sqlCmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = username; sqlCmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = firstName; sqlCmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = lastName; sqlCmd.Parameters.Add("@Gender", SqlDbType.TinyInt).Value = gender; sqlCmd.Parameters.Add("@LocationId", SqlDbType.Int).Value = locationId; sqlCmd.Parameters.Add("@BirthDate", SqlDbType.Date).Value = Convert.ToDateTime(birthDate);//Convert.ToDateTime(dob); sqlCmd.Parameters.Add("@HasPhoto", SqlDbType.Bit).Value = hasPhoto; //try //{ sqlConn.Open(); sqlCmd.ExecuteNonQuery(); //} //catch (Exception ex) //{ //} //finally //{ sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); //} Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(userId, 1, Convert.ToInt64(userId)); string email = ui.getEmailByUserId(userId); string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString(); string link = siteLink; string message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='" + link + "'>CLICK HERE</a> to visit the website.<br/><br/>CityCowd Team"; if(!ui.isUserEmailVerified(userId)) { string VCode = Convert.ToString(Guid.NewGuid()); SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd2 = new SqlCommand("sp_verifyEmailAdd", sqlConn2); sqlCmd2.CommandType = CommandType.StoredProcedure; sqlCmd2.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; sqlCmd2.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = VCode; sqlConn2.Open(); sqlCmd2.ExecuteNonQuery(); link = siteLink + "Verify/Email/" + VCode; message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='" + link + "'>CLICK HERE</a> to verify your email address and visit the website.<br/><br/>CityCowd Team"; } Classes.Mail m = new Classes.Mail(); int status2 = m.sendMail("register", email, "Hi, " + firstName + message, ""); } } } return status; }
public int requestAccept(int userId, Int64 requestId) { int status = 0; DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_requestInfo", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@OwnerId", SqlDbType.Int).Value = userId; sda.SelectCommand.Parameters.Add("@RequestId", SqlDbType.BigInt).Value = requestId; try { sda.Fill(ds); dt = ds.Tables[0]; } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); } if (dt.Rows.Count != 0)// request exists { int userId1 = Convert.ToInt32(dt.Rows[0]["UserId"].ToString()); Int64 eventId = Convert.ToInt64(dt.Rows[0]["EventId"].ToString()); SqlConnection sqlConn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd1 = new SqlCommand("sp_requestAccept", sqlConn1); sqlCmd1.CommandType = CommandType.StoredProcedure; sqlCmd1.Parameters.Add("@OwnerId", SqlDbType.Int).Value = userId; sqlCmd1.Parameters.Add("@RequestId", SqlDbType.BigInt).Value = requestId; sqlCmd1.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd1.Parameters.Add("@UserId", SqlDbType.Int).Value = userId1; try { sqlConn1.Open(); sqlCmd1.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn1.Close(); sqlCmd1.Dispose(); sqlConn1.Dispose(); } // add notification Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(userId1, 2, eventId); Classes.Events ev = new Classes.Events(); int remained = ev.eventParticipantsRemained(eventId); if (remained == 0) { n.notificationAdd(userId, 3, eventId); } status = 1; } else { status = -1; } return(status); }
public int requestSend(int userId, Int64 eventId, string message) { int totalStatus = 0; Classes.Events ev = new Classes.Events(); if (ev.isUserOwner(userId, eventId)) { totalStatus = -1; } else if (ev.isUserParticipant(userId, eventId)) { //cancel participation SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventCancelParticipation", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); } Classes.Events e = new Classes.Events(); int ownerId = e.getOwnerIdByEventId(eventId); Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(ownerId, 7, Convert.ToInt64(userId)); totalStatus = 1; } else { int status = checkRequest(userId, eventId); if (status == 0) { //send request SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventRequestAdd", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; sqlCmd.Parameters.Add("@Message", SqlDbType.NVarChar).Value = message; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); } Classes.Events e1 = new Classes.Events(); int personId = e1.getOwnerIdByEventId(eventId); Classes.Signal s = new Classes.Signal(); s.usernotificationsNumber(personId); totalStatus = 3; } else if (status == 1) { //cancel request SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventRequestDelete", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); } Classes.Events e1 = new Classes.Events(); int personId = e1.getOwnerIdByEventId(eventId); Classes.Signal s = new Classes.Signal(); s.usernotificationsNumber(personId); totalStatus = 2; } } return(totalStatus); }
public int removeParticipant(int ownerId, int userId, Int64 eventId) { int status = 0; //0 user not owner 1 participants cancelled 2 user was not participant Classes.Events ev = new Classes.Events(); if (!ev.isUserOwner(ownerId, eventId)) { status = 0; } else { bool participantStatus = ev.isUserParticipant(userId, eventId); if(!participantStatus) { status = 2; } else { status = 1; SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventRemoveParticipant", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); } Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(userId, 8, eventId); } } return status; }
public int requestAccept(int userId, Int64 requestId) { int status = 0; DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_requestInfo", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@OwnerId", SqlDbType.Int).Value = userId; sda.SelectCommand.Parameters.Add("@RequestId", SqlDbType.BigInt).Value = requestId; try { sda.Fill(ds); dt = ds.Tables[0]; } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); } if (dt.Rows.Count != 0)// request exists { int userId1 = Convert.ToInt32(dt.Rows[0]["UserId"].ToString()); Int64 eventId = Convert.ToInt64(dt.Rows[0]["EventId"].ToString()); SqlConnection sqlConn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd1 = new SqlCommand("sp_requestAccept", sqlConn1); sqlCmd1.CommandType = CommandType.StoredProcedure; sqlCmd1.Parameters.Add("@OwnerId", SqlDbType.Int).Value = userId; sqlCmd1.Parameters.Add("@RequestId", SqlDbType.BigInt).Value = requestId; sqlCmd1.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd1.Parameters.Add("@UserId", SqlDbType.Int).Value = userId1; try { sqlConn1.Open(); sqlCmd1.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn1.Close(); sqlCmd1.Dispose(); sqlConn1.Dispose(); } // add notification Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(userId1, 2, eventId); Classes.Events ev = new Classes.Events(); int remained = ev.eventParticipantsRemained(eventId); if (remained == 0) { n.notificationAdd(userId, 3, eventId); } status = 1; } else { status = -1; } return status; }
public int requestSend(int userId, Int64 eventId, string message) { int totalStatus = 0; Classes.Events ev = new Classes.Events(); if (ev.isUserOwner(userId, eventId)) { totalStatus = -1; } else if (ev.isUserParticipant(userId, eventId)) { //cancel participation SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventCancelParticipation", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); } Classes.Events e = new Classes.Events(); int ownerId = e.getOwnerIdByEventId(eventId); Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(ownerId, 7, Convert.ToInt64(userId)); totalStatus = 1; } else { int status = checkRequest(userId, eventId); if (status == 0) { //send request SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventRequestAdd", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; sqlCmd.Parameters.Add("@Message", SqlDbType.NVarChar).Value = message; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); } Classes.Events e1 = new Classes.Events(); int personId = e1.getOwnerIdByEventId(eventId); Classes.Signal s = new Classes.Signal(); s.usernotificationsNumber(personId); totalStatus = 3; } else if (status == 1) { //cancel request SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventRequestDelete", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn.Close(); sqlCmd.Dispose(); sqlConn.Dispose(); } Classes.Events e1 = new Classes.Events(); int personId = e1.getOwnerIdByEventId(eventId); Classes.Signal s = new Classes.Signal(); s.usernotificationsNumber(personId); totalStatus = 2; } } return totalStatus; }
public int eventDelete(Int64 eventId, int userId) { int status = 0; DataTable dtParticipants = eventParticipants(eventId); for (int i = 0; i < dtParticipants.Rows.Count; i++) { int participantId = Convert.ToInt32(dtParticipants.Rows[i]["UserId"].ToString()); if(userId == participantId) { continue; } Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(participantId, 9, userId); } SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_eventDelete", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; //try //{ sqlConn.Open(); sqlCmd.ExecuteNonQuery(); //} //catch //{ //} //finally //{ sqlConn.Close(); sqlConn.Dispose(); sqlCmd.Dispose(); //} status = 1; return status; }
public int followAction(int userId, int profileId) { // is visitor follower int status = 0; DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_isUserFollower", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = profileId; sda.SelectCommand.Parameters.Add("@FollowerId", SqlDbType.Int).Value = userId; //try //{ sda.Fill(ds); dt = ds.Tables[0]; SqlCommand sqlCmd = new SqlCommand("sp_followUser", sqlConn); if (dt.Rows.Count == 0) { sqlCmd = new SqlCommand("sp_followUser", sqlConn); status = 1; // add notification Classes.Notifications n = new Classes.Notifications(); n.notificationAdd(profileId, 4, Convert.ToInt64(userId)); } else { sqlCmd = new SqlCommand("sp_unfollowUser", sqlConn); status = 2; } //try //{ sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = profileId; sqlCmd.Parameters.Add("@FollowerId", SqlDbType.Int).Value = userId; sqlConn.Open(); sqlCmd.ExecuteNonQuery(); //} //catch //{ //} //finally //{ sqlConn.Close(); sqlConn.Dispose(); sqlCmd.Dispose(); //} //} //catch (Exception ex) //{ //} //finally //{ sqlConn.Close(); sda.Dispose(); //} return(status); }