Ejemplo n.º 1
0
        public static bool deleteTag(Tag tag)
        {
            using (var _context = new DbofSimpleNoteEntities())
            {
                var get = (from gettag in _context.Tags
                           where gettag.TenTag == tag.TenTag
                           select gettag).SingleOrDefault();


                foreach (var note in get.Notes)
                {
                    foreach (var temp in note.Tags)
                    {
                        if (temp.TenTag == tag.TenTag)
                        {
                            note.Tags.Remove(temp);
                            break;
                        }
                    }
                }
                _context.Tags.Remove(get);
                _context.SaveChanges();
                return(true);
            }
        }
Ejemplo n.º 2
0
 public static bool updateNote(Note note)
 {
     using (var _context = new DbofSimpleNoteEntities())
     {
         _context.Notes.AddOrUpdate(note);
         _context.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 3
0
 public static bool addTag(Tag tag)
 {
     using (var _context = new DbofSimpleNoteEntities())
     {
         _context.Tags.Add(tag);
         _context.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 4
0
 public static bool deleteNote(Note note)
 {
     using (var _context = new DbofSimpleNoteEntities())
     {
         var get = (from getnote in _context.Notes
                    where getnote.SoThuTu == note.SoThuTu
                    select getnote).SingleOrDefault();
         foreach (var gettag in get.Tags)
         {
             foreach (var temp in gettag.Notes)
             {
                 if (temp.SoThuTu == note.SoThuTu)
                 {
                     gettag.Notes.Remove(temp);
                     break;
                 }
             }
         }
         _context.Notes.Remove(get);
         _context.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 5
0
 public static bool addNote(Note note)
 {
     try
     {
         using (var _context = new DbofSimpleNoteEntities())
         {
             foreach (var temp in note.Tags)
             {
                 var get = (from gettag in _context.Tags
                            where gettag.TenTag == temp.TenTag
                            select gettag).Single();
                 get.Notes.Add(note);
             }
             note.Tags.Clear();
             _context.Notes.Add(note);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }