public virtual void SaveAddress(AdresseTable address)
 {
     using (var ctx = new notetalocEntities())
     {
         var add = ctx.AdresseTables.Where(a => a.GeoCodeResponse == address.GeoCodeResponse).FirstOrDefault();
         if (add == null)
         {
             address.AdresseId = GetAddresseId(DateTime.Now);
             ctx.AdresseTables.Add(address);
             ctx.SaveChanges();
         }
     }
 }
 public virtual void SaveNote(NoteTable note, out string resultMessage)
 {
      using (var ctx = new notetalocEntities())
     {
      var noteToAdd = ctx.NoteTables.Where(n => n.AdresseId == note.AdresseId && n.UserId == note.UserId).FirstOrDefault();
          
      if (noteToAdd == null)
      {
          note.NoteId = GetNoteId(DateTime.Now);
          ctx.NoteTables.Add(note);
          ctx.SaveChanges();
          resultMessage = "Add";
      }
      else
      {
          note.NoteId = noteToAdd.NoteId;
          noteToAdd.Note = note.Note;
          ctx.SaveChanges();
          resultMessage = "Update";
      }
     }
 }
 public virtual void UpdateNoteStatus(NoteTable note)
 {
     using (var ctx = new notetalocEntities())
     {
         var noteToUpdate = ctx.NoteTables.Where(n => n.NoteId == note.NoteId).FirstOrDefault();
         noteToUpdate.StatutNote = 1;
         ctx.SaveChanges();
     }
 }
 public virtual int GetAddressId(AdresseTable address)
 {
     using (var ctx = new notetalocEntities())
     {
         return ctx.AdresseTables.SingleOrDefault(a => a.GeoCodeResponse == address.GeoCodeResponse).AdresseId;
     }
 }