Esempio n. 1
0
        public static List <ContactData> GetActiveRecordsFromDB()
        {
            List <ContactData> contacts = new List <ContactData>();

            using (AddressBookDB db = new AddressBookDB())
            {
                /** c.Deprecated.Year == 0 - picks out only active records
                 *  which weren't removed from UI **/

                contacts = (from c in db.Contacts
                            where c.DeprecationDate.Year == 0
                            select c
                            ).ToList();
            }

            // Process records to get them in proper format to compare with records from
            // UI representation level
            List <ContactData> contacts2 = new List <ContactData>();

            foreach (ContactData c in contacts)
            {
                contacts2.Add(Utils.PrepareEntityForContactsView(c));
            }

            return(contacts2);
        }
Esempio n. 2
0
 public static List <GroupData> GetAllFromDB()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from g in db.Groups select g).ToList()); //запрос в БД списка групп
     }
 }
 public static List <AddressData> GetAll()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from a in db.Address.Where(x => x.Deprecated == "0000-00-00 00:00:00") select a).ToList());
     }
 }
Esempio n. 4
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());
     }//закрывается база данных автоматически
 }
Esempio n. 5
0
 public static List <GroupData> GetGroupWithContacts()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return(db.Groups.Where(x => x.Deprecated == "0000-00-00 00:00:00" && db.GCR.Select(y => y.GroupId).Contains(x.Id)).ToList());
     }
 }
Esempio n. 6
0
 public List <ContactData> GetContacts()
 {
     using (AddressBookDB db = new AddressBookDB()) { // for auto close DB at the end using
         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());
     };
 }
Esempio n. 7
0
 public static List <GroupData> GetAll()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from g in db.Groups select g).ToList());
     }
 }
Esempio n. 8
0
 public static List <ContactData> GetAll()
 {
     using (AddressBookDB addressBookDB = new AddressBookDB())
     {
         return((from g in addressBookDB.Contacts.Where(x => x.Deprecated == "0000-00-00 00:00:00") select g).ToList());
     }
 }
        public static GroupData GetNonEmptyGroup()
        {
            List <GroupData> groups = new List <GroupData>();

            using (AddressBookDB db = new AddressBookDB())
            {
                groups = (from g in db.Groups select g).ToList();

                if (groups.Count() == 0)
                {
                    // Nothing to process further, so we return 'null' right here
                    return(null);
                }
            }

            foreach (GroupData group in groups)
            {
                if (group.GetContacts().Count() > 0)
                {
                    return(group);
                }
            }

            // if no proper object were found return 'null'
            return(null);
        }
Esempio n. 10
0
 public static List <GroupData> GetAll()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from g in db.Groups.Where(x => x.Depricated == "0000 - 00 - 00 00:00:00") select g).ToList());
     }
 }
Esempio n. 11
0
 static public 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());
     }
 }
Esempio n. 12
0
 public static List <ContactData> GetAll()
 {
     using (AddressBookDB db = new AddressBookDB())
     { // for auto close DB at the end using
         return((from c in db.Contacts.Where(x => x.Deprecated == "0000-00-00 00:00:00") select c).ToList());
     };
 }
Esempio n. 13
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()); //возвращает список контактов, у которыйх в Deprecated указанное значение
     }
 }
Esempio n. 14
0
 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());
     }
 }
Esempio n. 15
0
 public static List <ContactData> GetContactsWithoutGroup()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return(db.Contacts.Where(x => x.Deprecated == "0000-00-00 00:00:00" && !db.GCR.Select(y => y.ContactId).Contains(x.Id)).ToList());
     }
 }
Esempio n. 16
0
 public List <GroupData> GetGroupWithContacts()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return(db.Groups.Where(g => db.GCR.Any(gcr => gcr.GroupId == g.Id) && g.Deprecated == "0000-00-00 00:00:00").Distinct().ToList());
     }
 }
Esempio n. 17
0
 public static List <GroupData> GetAll()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from g in db.Groups select g).ToList());
     }//закрывается база данных автоматически
 }
Esempio n. 18
0
 public List <GroupContactRelation> ContactEnteredToGroup(string contactId, string groupId)
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from gcr in db.GCR.Where(p => p.ContactId == contactId && p.GroupId == groupId)
                 select gcr).Distinct().ToList());
     }
 }
Esempio n. 19
0
 public static List <ContactData> GetAllFromDB()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from c in db.Contacts.Where(x => x.Deprecated == "0000-00-00 00:00:0")
                 select c).ToList()); //запрос в БД списка групп
     }
 }
Esempio n. 20
0
 public static List <ContactData> GetContactDatafromDB(string firstname)
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from g in db.Contacts.Where(x => x.Deprecated == "0000-00-00 00:00:00" &&
                                             x.Firstname == firstname) select g).ToList());
     }
 }
Esempio n. 21
0
 public List <ContactsData> GetContacts()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from c in db.Contacts
                 from gsr in db.GCR.Where(p => p.GroupId == Id && p.ContactId == c.Id) select c).Distinct().ToList());
     }
 }
Esempio n. 22
0
 public static ContactData GetLastContact()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         List <ContactData> contacts = (from c in db.Contacts.Where(x => x.Deprecated == "0000-00-00 00:00:00") select c).ToList();
         return(contacts.Last());
     }
 }
Esempio n. 23
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());         //возвращает список из бд
     }
 }
Esempio n. 24
0
 public List <GroupData> GetGroupsByContact()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from g in db.Groups
                 from gcr in db.GCR.Where(p => p.ContactId == Id && p.GroupId == g.Id)
                 select g).ToList());
     }
 }
Esempio n. 25
0
 public List <ContactData> GetContacts()
 {
     using (AddressBookDB addressBookDB = new AddressBookDB())
     {
         return((from c in addressBookDB.Contacts
                 from gcr in addressBookDB.GCR.Where(p => p.GroupId == Id && p.ContactId == c.Id && c.Deprecated == "0000-00-00 00:00:00")
                 select c).ToList());
     }
 }
Esempio n. 26
0
 public List <UserData> 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());
     }
 }
Esempio n. 27
0
 public static List <GroupData> GetGroups()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from g in db.Groups
                 from gcr in db.GCR.Where(p => p.Groupid == g.Id)
                 select g).Distinct().ToList());
     }
 }
Esempio n. 28
0
 public List <AddressData> GetAddresses()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from a in db.Addresses
                 from gar in db.GAR.Where(p => p.GroupID == ID && p.AddresssID == a.ID)
                 select a).Distinct().ToList());
     }
 }
 public List <AddressData> GetAddress()
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         return((from a in db.Address
                 from gar in db.GAR.Where(p => p.GroupId == Id && p.AddressId == a.Id && a.Deprecated == "0000-00-00 00:00:00")
                 select a).Distinct().ToList());
     }
 }
 public void SelectGroupToRemove(string groupId, string contactId)
 {
     using (AddressBookDB db = new AddressBookDB())
     {
         (from gcr in db.GCR
          .Where(t => t.ContactId == contactId && t.GroupId == groupId)
          select gcr).Delete();
     }
 }