예제 #1
0
        public static bool Save(long PersonID, long CommunityID)
        {
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    DbCommand oCommand = oDatabase.GetStoredProcCommand("sp_CommunityNewsSummaryRepository_InsertUpdate");
                    oDatabase.AddInParameter(oCommand, "@CommunityID", System.Data.DbType.Int64, CommunityID);
                    oDatabase.AddInParameter(oCommand, "@PersonID", System.Data.DbType.Int64, PersonID);
                    oCommand.Connection = connection;
                    if (oCommand.ExecuteNonQuery() == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("NotificationToPersonRepository", ex.Message);
                    return(false);
                }
            }
        }
        public static bool RemoveNotificationForUser(Guid NotificationID, int PersonID)
        {
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    DbCommand oCommand = oDatabase.GetStoredProcCommand("sp_RemoveNotificationForUser");
                    oDatabase.AddInParameter(oCommand, "@NotificationID", System.Data.DbType.Guid, NotificationID);
                    oDatabase.AddInParameter(oCommand, "@PersonID", System.Data.DbType.Int32, PersonID);
                    oCommand.Connection = connection;
                    if (oCommand.ExecuteNonQuery() == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("RemoveNotificationForUser", ex.Message);
                    return(false);
                }
            }
        }
        public static bool Add(PersonNotification oNotification)
        {
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection()){
                connection.Open();
                try{
                    DbCommand oCommand = oDatabase.GetStoredProcCommand("sp_NotificationToPersonRepository_Add");
                    oDatabase.AddInParameter(oCommand, "@UniqueID", System.Data.DbType.Guid, oNotification.NotificationUniqueID);
                    oDatabase.AddInParameter(oCommand, "@PersonID", System.Data.DbType.Int64, oNotification.PersonID);
                    oDatabase.AddInParameter(oCommand, "@ID", System.Data.DbType.Guid, System.Guid.NewGuid());
                    oDatabase.AddInParameter(oCommand, "@Day", System.Data.DbType.DateTime, oNotification.Day);
                    oDatabase.AddInParameter(oCommand, "@CommunityID", System.Data.DbType.Int64, oNotification.CommunityID);
                    oDatabase.AddInParameter(oCommand, "@SentDate", System.Data.DbType.DateTime, oNotification.SentDate);
                    oCommand.Connection = connection;
                    if (oCommand.ExecuteNonQuery() == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex) {
                    System.Diagnostics.EventLog.WriteEntry("NotificationToPersonRepository", ex.Message);
                    return(false);
                }
            }
        }
예제 #4
0
        public static bool Save(CommunityNewsSummary reminder)
        {
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    DbCommand oCommand;
                    if (reminder.ID == System.Guid.Empty)
                    {
                        oCommand    = oDatabase.GetStoredProcCommand("sp_CommunityNewsSummaryRepository_Add");
                        reminder.ID = System.Guid.NewGuid();
                    }
                    else
                    {
                        oCommand = oDatabase.GetStoredProcCommand("sp_CommunityNewsSummaryRepository_Update");
                    }
                    oDatabase.AddInParameter(oCommand, "@CommunityID", System.Data.DbType.Int64, reminder.CommunityID);
                    oDatabase.AddInParameter(oCommand, "@CountAction", System.Data.DbType.Int64, reminder.ActionCount);
                    oDatabase.AddInParameter(oCommand, "@PersonID", System.Data.DbType.Int64, reminder.PersonID);
                    oDatabase.AddInParameter(oCommand, "@ID", System.Data.DbType.Guid, reminder.ID);
                    oCommand.Connection = connection;
                    if (oCommand.ExecuteNonQuery() == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("CommunityNewsSummaryRepository", ex.Message);
                    return(false);
                }
            }
        }