示例#1
0
 public EntryVote Add(EntryVote entryVote)
 {
     try
     {
         using (SQLiteConnection sqliteConnection = new SQLiteConnection(this.connectionString))
         {
             sqliteConnection.Open();
             SQLiteCommand sqlCommand = new SQLiteCommand(SQLiteDataRepository.SQL_ACCOUNT_INSERT, sqliteConnection);
             sqlCommand.Parameters.AddWithValue("@EntryID", entryVote.EntryID);
             sqlCommand.Parameters.AddWithValue("@AccountID", entryVote.AccountID);
             sqlCommand.Parameters.AddWithValue("@Vote", entryVote.Vote);
             object returnValue = sqlCommand.ExecuteScalar();
             int id = int.Parse(returnValue.ToString());
             entryVote.ID = id;
         }
         return entryVote;
     }
     catch (Exception exception)
     {
         return null;
     }
 }
示例#2
0
        public EntryVote GetEntryVote(int entryID, int accountID)
        {
            try
            {
                EntryVote entryVote = new EntryVote();
                using (SQLiteConnection sqliteConnection = new SQLiteConnection(this.connectionString))
                {
                    sqliteConnection.Open();
                    SQLiteCommand sqlCommand = new SQLiteCommand(SQLiteDataRepository.SQL_EntryVote_SELECT, sqliteConnection);
                    sqlCommand.Parameters.AddWithValue("@EntryID", entryID);
                    sqlCommand.Parameters.AddWithValue("@AccountID", accountID);

                    using (SQLiteDataReader reader = sqlCommand.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            entryVote.ID = reader.GetInt32(0);
                            entryVote.EntryID = reader.GetInt32(1);
                            entryVote.AccountID = reader.GetInt32(2);
                            entryVote.Vote = reader.GetInt32(3);
                        }
                    }
                }
                return entryVote;
            }
            catch (Exception exception)
            {
                return null;
            }
        }