Ejemplo n.º 1
0
        public Dictionary<ContactFriendsStatus, int> FriendsMap(List<string> usernames, ContactSearchParams contactSearchParams)
        {
            var friendsMap = new FriendsBUS().FriendsCount();
            var mapQuery = from c in Contacts
                                        where (contactSearchParams.SelectedUsernameLetters.Count() == 0 || contactSearchParams.SelectedUsernameLetters.Contains(c.Username.Substring(0, 1)))
                                        &&
                                        (contactSearchParams.SelectedUserAccountStatus.Count() == 0 || (usernames.Contains(c.Username) && contactSearchParams.SelectedUserAccountStatus.Contains(ContactUserAccountStatus.UserAccount)) || (!usernames.Contains(c.Username) && contactSearchParams.SelectedUserAccountStatus.Contains(ContactUserAccountStatus.NoUserAccount)))
                                        group c by friendsMap.ContainsKey(c.Id)
                                            into g
                                            select new { HasFriends = g.Key, Count = g.Count() };

            var list = mapQuery.ToList();

            var map = mapQuery.ToDictionary(g => g.HasFriends ? ContactFriendsStatus.HasFriends : ContactFriendsStatus.NoFriends, g => g.Count);
            return map;
        }
Ejemplo n.º 2
0
        public Dictionary<string, int> UsernameMap(List<string> usernames, ContactSearchParams contactSearchParams)
        {
            var friendsMap = new FriendsBUS().FriendsCount();
            var usernameMapResults = from c in Contacts
                                     where (contactSearchParams.SelectedUserAccountStatus.Count() == 0 || (usernames.Contains(c.Username) && contactSearchParams.SelectedUserAccountStatus.Contains(ContactUserAccountStatus.UserAccount)) || (!usernames.Contains(c.Username) && contactSearchParams.SelectedUserAccountStatus.Contains(ContactUserAccountStatus.NoUserAccount)))
                                     &&
                                        (contactSearchParams.SelectedFriendsStatus.Count() == 0 || (friendsMap.Keys.Contains(c.Id) && contactSearchParams.SelectedFriendsStatus.Contains(ContactFriendsStatus.HasFriends)) || (!friendsMap.Keys.Contains(c.Id) && contactSearchParams.SelectedFriendsStatus.Contains(ContactFriendsStatus.NoFriends)))
                                     group c by c.Username.Substring(0, 1).ToUpper()
                                         into g
                                         select new { Letter = g.Key, Count = g.Count() };

            var usernameMap = usernameMapResults.ToDictionary(g => g.Letter, g => g.Count);
            return usernameMap;
        }