Пример #1
0
 public virtual void AddRange(NotesList addedRange)
 {
     if (addedRange.notes.Count > 0)
     {
         foreach (var kvp in addedRange.notes)
         {
             if (notes.ContainsKey(kvp.Key))
                 SolveIdConflictWhenAddNewNote(kvp.Value);
             else
                 notes.Add(kvp.Key, kvp.Value);
         }
         SaveNotes();
     }
 }
Пример #2
0
 public void RemoveNotesFromUser(string userName, NotesList removeNotes)
 {
     var oldNotes = GetUserNotes(userName);
     oldNotes.RemoveRange(removeNotes);
 }
Пример #3
0
 public void ModifyNotesToUser(string userName, NotesList modifiedNotes)
 {
     var oldNotes = GetUserNotes(userName);
     oldNotes.ModifyRange(modifiedNotes);
 }
Пример #4
0
 public void AddNotesToUser(string userName, NotesList AddedNotes)
 {
     var oldNotes = GetUserNotes(userName);
     oldNotes.AddRange(AddedNotes);
 }
Пример #5
0
 public void OnRemoveNotes(NotesList notes)
 {
     var res = RemoveRange(notes);
     if (res && NotesDeleted!= null)
         NotesDeleted(notes.GetNotes());
 }
Пример #6
0
 public void OnModifyNotes(NotesList notes)
 {
     var res = ModifyRange(notes);
     if (res && NotesModified != null)
         NotesModified(notes.GetNotes());
 }
Пример #7
0
 public void OnAddNotes(NotesList notes)
 {
     AddRange(notes);
     if (NotesAdded != null)
         NotesAdded(notes.GetNotes());
 }
Пример #8
0
 public virtual bool RemoveRange(NotesList removedRange)
 {
     bool res = false;
     if (removedRange.notes.Count > 0)
     {
         var confirmed = new List<uint>();
         foreach (var n in removedRange.notes)
         {
             if (notes.Remove(n.Key))
                 confirmed.Add(n.Key);
         }
         res = confirmed.Count > 0;
         foreach (var c in confirmed)
             notes.Remove(c);
         if (res)
             SaveNotes();
     }
     return res;
 }
Пример #9
0
 public virtual bool ModifyRange(NotesList modifiedRange)
 {
     bool res = false;
     if (modifiedRange.notes.Count > 0)
     {
         var confirmed = new List<uint>();
         foreach (var n in modifiedRange.notes)
         {
             if (notes.ContainsKey(n.Key))
             {
                 notes[n.Key] = n.Value;
                 confirmed.Add(n.Key);
             }
         }
         res = confirmed.Count > 0;
         if (res)
             SaveNotes();
     }
     return res;
 }
Пример #10
0
 public static bool SyncNotes(NotesList notes, NotesSyncType syncType)
 {
     return SendMessage(new CToSNotesRequest() { notes = notes, syncType = syncType });
 }