Пример #1
0
 public bool Save(Notes note)
 {
     try
     {
         using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
         {
             db.Notes.InsertOnSubmit(note);
             db.SubmitChanges();
         }
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Пример #2
0
 public bool Save(Notes note)
 {
     try
     {
         using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
         {
             db.Notes.InsertOnSubmit(note);
             db.SubmitChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #3
0
 public bool DestroyOldNotes(int days)
 {
     try
     {
         using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
         {
             var destroy = db.Notes.Where(t => t.date < DateTime.Now.AddDays(-days)).ToList();
             db.Notes.DeleteAllOnSubmit(destroy);
             db.SubmitChanges();
             return true;
         }
     }
     catch (Exception)
     {
         return false;
     }
 }
Пример #4
0
 public bool Destroy(Notes note)
 {
     try
     {
         using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
         {
             var excluir = db.Notes.Where(t => t.id == note.id).First();
             db.Notes.DeleteOnSubmit(excluir);
             db.SubmitChanges();
         }
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Пример #5
0
 public bool Destroy(Notes note)
 {
     try
     {
         using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
         {
             var excluir = db.Notes.Where(t => t.id == note.id).First();
             db.Notes.DeleteOnSubmit(excluir);
             db.SubmitChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #6
0
 public bool DestroyOldNotes(int days)
 {
     try
     {
         using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
         {
             var destroy = db.Notes.Where(t => t.date < DateTime.Now.AddDays(-days)).ToList();
             db.Notes.DeleteAllOnSubmit(destroy);
             db.SubmitChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #7
0
        //ToDo Update note using Linq

        internal bool UpdateNote(int id, string note)
        {
            try
            {
                using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
                {
                    Notes update = (from tar in db.Notes
                                    where tar.id == id
                                    select tar).First();

                    update.note = note;
                    db.SubmitChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #8
0
        //ToDo Update note using Linq
        internal bool UpdateNote(int id, string note)
        {
            try
            {
                using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
                {
                    Notes update = (from tar in db.Notes
                                     where tar.id == id
                                     select tar).First();

                    update.note = note;
                    db.SubmitChanges();

                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }