Esempio n. 1
0
        public static List <Group> GetAll()
        {
            using (var db = new AddressbookDataBase())
            {
                var query =
                    from groups in db.Groups
                    select groups;

                return(query.ToList());
            }
        }
Esempio n. 2
0
        public static List <Contact> GetAll()
        {
            using (var db = new AddressbookDataBase())
            {
                var query =
                    from contacts in db.Contacts
                    select contacts;

                return(query.ToList());
            }
        }
Esempio n. 3
0
        public static Group GetGroupById(string id)
        {
            using (var db = new AddressbookDataBase())
            {
                var query =
                    from groups in db.Groups
                    where groups.Id == id
                    select groups;

                return(query.FirstOrDefault());
            }
        }
Esempio n. 4
0
        public static Contact GetContactById(string id)
        {
            using (var db = new AddressbookDataBase())
            {
                var query =
                    from contacts in db.Contacts
                    where contacts.Id == id
                    select contacts;

                return(query.FirstOrDefault());
            }
        }
Esempio n. 5
0
        public static List <Contact> GetBirthdays()
        {
            using (var db = new AddressbookDataBase())
            {
                var query =
                    from contacts in db.Contacts
                    where contacts.Birthday != "0" &&
                    contacts.Birthyear != "-"
                    select contacts;

                return(query.ToList());
            }
        }
Esempio n. 6
0
        public static List <Contact> GetContactsNotInGroups()
        {
            using (var db = new AddressbookDataBase())
            {
                var query =
                    from contacts in db.Contacts
                    join groupContactRelations in db.GroupContactRelations on contacts.Id equals groupContactRelations.Id into table1
                    from newcontacts in table1.DefaultIfEmpty()
                    where newcontacts.Group_Id == null
                    select contacts;

                return(query.ToList());
            }
        }
Esempio n. 7
0
        public static List <Contact> GetContactsInGroup(string id)
        {
            using (var db = new AddressbookDataBase())
            {
                var query =
                    from groupContactRelations in db.GroupContactRelations
                    join contacts in db.Contacts on groupContactRelations.Id equals contacts.Id
                    where groupContactRelations.Group_Id == id
                    //join groups in db.Groups on groupContactRelations.Group_Id equals groups.Id
                    select contacts;

                return(query.ToList());
            }
        }