public static List <GroupData> GetAll() { using (AddressBookDB db = new AddressBookDB()) { return((from g in db.Groups select g).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()); } }
public List <ContactData> GetContacts() { using (AddressBookDB db = new AddressBookDB()) { return((from c in db.Contacts from gcr in db.GCR.Where(p => p.GroupId == Id && p.ContactId == c.Id && c.Deprecated == "0000-00-00 00:00:00") select c).Distinct().ToList()); } }
public void CheckForContactsInGroupsAddIfNot() { using (AddressBookDB db = new AddressBookDB()) { int count = (from c in db.Contacts from gcr in db.GCR.Where(p => p.ContactId == c.Id) select c).Distinct().Count(); if (count == 0) { ContactData contactUpdated = ContactData.GetAll()[0]; GroupData group = GroupData.GetAll()[0]; AddContactToGroup(contactUpdated, group); } } }
public void TestDBConnectivity() { DateTime start = DateTime.Now; List <GroupData> fromUi = app.Groups.GetGroupList(); DateTime end = DateTime.Now; System.Console.Out.WriteLine(end.Subtract(start)); start = DateTime.Now; AddressBookDB db = new AddressBookDB(); List <GroupData> fromDb = (from g in db.Groups select g).ToList(); db.Close(); end = DateTime.Now; System.Console.Out.WriteLine(end.Subtract(start)); }
public ContactData CheckGroupCountCreateContactIfAll(ContactData contact) { using (AddressBookDB db = new AddressBookDB()) { int count = (from c in db.Contacts from g in db.Groups from gcr in db.GCR.Where(p => p.ContactId == contact.Id) select g).Distinct().Count(); int allGroups = GroupData.GetAll().Count(); if (count == allGroups) { ContactData contactAdded = new ContactData("pre-created", "pre-created"); CreateContactWholeProcess(contactAdded); return(contactAdded); } return(contact); } }