예제 #1
0
 public static List <GroupData> GetAll()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from g in db.Groups select g).ToList());
     }
 }
예제 #2
0
 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());
     }
 }
예제 #3
0
 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());
     }
 }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
        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));
        }
예제 #6
0
        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);
            }
        }