Beispiel #1
0
        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);
        }
Beispiel #2
0
        public int checkRequest(int userId, Int64 eventId)
        {
            int status = 0; //0 user has no request 1 user has requested before 2 user is a participant

            DataTable      dt      = new DataTable();
            DataSet        ds      = new DataSet();
            SqlConnection  sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlDataAdapter sda     = new SqlDataAdapter("sp_requestCheck", 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)// request exists
            {
                Classes.Events ev = new Classes.Events();
                bool           participantStatus = ev.isUserParticipant(userId, eventId);

                if (participantStatus)// user is a participant
                {
                    status = 2;
                }
            }
            else
            {
                status = 1;
            }

            return(status);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        public int checkRequest(int userId, Int64 eventId)
        {
            int status = 0; //0 user has no request 1 user has requested before 2 user is a participant

            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlDataAdapter sda = new SqlDataAdapter("sp_requestCheck", 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)// request exists
            {
                Classes.Events ev = new Classes.Events();
                bool participantStatus = ev.isUserParticipant(userId, eventId);

                if (participantStatus)// user is a participant
                {
                    status = 2;
                }
            }
            else
            {
                status = 1;
            }

            return status;
        }
Beispiel #6
0
        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;
        }