Exemplo n.º 1
0
 public int Add(Note note)
 {
     using (var db = new SampleServiceEntities())
     {
         db.Notes.Add(note);
         db.SaveChanges();
         return(note.Id);
     }
 }
Exemplo n.º 2
0
        public bool Delete(int id)
        {
            using (var db = new SampleServiceEntities())
            {
                var note = db.Notes.FirstOrDefault(x => x.Id == id);

                if (note == null)
                {
                    return(false);
                }

                db.Notes.Remove(note);
                db.SaveChanges();
                return(true);
            }
        }