예제 #1
0
 // Remove record from db
 public bool RemoveRecords()
 {
     using (MesInbox mi = new MesInbox())
     {
         try
         {
             mi.Table.RemoveRange(mi.Table);
             mi.SaveChanges();
         }catch (Exception ex)
         {
             WriteToLog(ex.Message);
             throw new Exception(ex.Message);
         }
     }
     return(true);
 }
예제 #2
0
        // Add  record to db
        public void AddRecord(string textParam)
        {
            using (MesInbox mi = new MesInbox())
            {
                try
                {
                    Table tb = new Table {
                        Text = textParam, IsRead = false
                    };

                    mi.Table.Add(tb);
                    mi.SaveChanges();
                }catch (Exception ex)
                {
                    WriteToLog(ex.Message);
                    throw new Exception(ex.Message);
                }
            }
        }
예제 #3
0
        // Get Record from db
        public List <Table> GetRecords()
        {
            List <Table> retTable = new List <Table>();

            using (MesInbox mi = new MesInbox())
            {
                try
                {
                    foreach (Table t in mi.Table)
                    {
                        retTable.Add(t);
                    }
                }catch (Exception ex)
                {
                    WriteToLog(ex.Message);
                    throw new Exception(ex.Message);
                }
            }
            return(retTable);
        }
예제 #4
0
        // Updater record in db
        public void UpdateRecord(Table tb)
        {
            using (MesInbox mi = new MesInbox())
            {
                try
                {
                    Table tbl = mi.Table.Find(tb.id);

                    if (tbl != null)
                    {
                        tbl = tb;
                        mi.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    WriteToLog(ex.Message);
                    throw new Exception(ex.Message);
                }
            }
        }