public List <ContactData> GetContactsListWithGroup(string groupId)
 {
     using (AddressbookDB db = new AddressbookDB())
     {
         return((from c in db.Contacts from gcr in db.GCR.Where(p => p.GroupId == groupId && p.ContactId == c.Id && c.Deprecated == "0000-00-00 00:00:00") select c).Distinct().ToList());
     }
 }
 public static List <ContactData> GetAll()
 {
     using (AddressbookDB db = new AddressbookDB())
     {
         return((from c in db.Contacts.Where(x => x.Deprecated == "0000-00-00 00:00:00") select c).ToList());
     }
 }
Example #3
0
 public static List <GroupData> GetAll()
 {
     using (AddressbookDB db = new AddressbookDB())
     {
         return((from g in db.Groups select g).ToList());
     }
 }
 public int AddNewRelation(int contactId, int groupId)
 {
     using (var db = new AddressbookDB())
     {
         return(db.GCR
                .Value(gcr => gcr.ContactId, contactId.ToString())
                .Value(gcr => gcr.GroupId, groupId.ToString())
                .Insert());
     }
 }
 public int?AddContact(ContactData contact)
 {
     using (AddressbookDB db = new AddressbookDB())
     {
         return(db.Contacts
                .Value(c => c.FirstName, contact.FirstName)
                .Value(c => c.LastName, contact.LastName)
                .InsertWithInt32Identity());
     }
 }
Example #6
0
 public int?AddGroup(GroupData group)
 {
     using (AddressbookDB db = new AddressbookDB())
     {
         return(db.Groups
                .Value(g => g.Name, group.Name)
                .Value(g => g.Header, group.Header)
                .Value(g => g.Footer, group.Footer)
                .InsertWithInt32Identity());
     }
 }