public ProfileIdVm()
 {
     var connect = new ConnectService();
     PendingIds = connect.GetConnectReqIds(ConnectStatusType.RequestSend);
     AcceptedIds = connect.GetConnectReqIds(ConnectStatusType.Accepted);
     RejectedIds = connect.GetConnectReqIds(ConnectStatusType.Rejected);
     PendingIds = RejectedIds.Concat(PendingIds).ToList();
 }
        public override void ComposeFilters(IEnumerable <User> users)
        {
            MasterFilters = FilterItems;
            FilterItems   = new List <FilterItem>();
            var connectSrv = new ConnectService();
            var connIds    = connectSrv.GetConnectReqIds(ConnectStatusType.Accepted);
            var connUsers  = users.Where(u => connIds.Contains(u.UserId))
                             .ToList();
            var cfItem = new FilterItem(_checkedItems.Contains(CONN))
            {
                Count     = connUsers.Count,
                ValueText = CONN
            };

            FilterItems.Add(cfItem);

            var ncfItem = new FilterItem(_checkedItems.Contains(N_CONN))
            {
                Count = users.Count() - connUsers.Count,
                //Count = users.Count(u => !u.IsRelative()) - connUsers.Count,
                ValueText = N_CONN
            };

            FilterItems.Add(ncfItem);
            MasterFilters = FilterItems;
        }
        public PartialViewResult Show(int? id)
        {
            var currUser = GetCurrentUser();
            var reqUser = GetUserByIdOrCurrent(id);
            var model = new ContactProfileVm(reqUser);
            using (var connect = new ConnectService())
            {
                var myConn = connect.GetConnectReqIds(ConnectStatusType.Accepted);
                if (reqUser.UserId != currUser.UserId && !currUser.IsAdmin())
                {
                    byte code = 0;
                    if (myConn.Contains(currUser.UserId)) code |= (0x01 << (byte)VisibilityType.Connections);
                    if (currUser.IsAlumni()) code |= (0x01 << (byte)VisibilityType.Alumni);
                    if (currUser.IsStudent()) code |= (0x01 << (byte)VisibilityType.Student);
                    if (currUser.IsStaff()) code |= (0x01 << (byte)VisibilityType.Staff);
                    if ((code & reqUser.MobileVisibility) == 0)
                    {
                        model.MobileNumber = "<NA>";
                    }

                    if ((code & reqUser.EmailVisibility) == 0)
                    {
                        model.Email = "<NA>";
                    }

                    if ((code & reqUser.HomePhoneVisibility) == 0)
                    {
                        model.HomePhone = "<NA>";
                    }
                }
            }
            // TODO email visibility
            ViewData[Constants.ProfileEditKey] = (currUser.UserId == reqUser.UserId);
            return PartialView(model);
        }
 public override IEnumerable<User> Execute(IEnumerable<User> users)
 {
     if (!_checkedItems.Any()) return users;
     var connectSrv = new ConnectService();
     var connIds = connectSrv.GetConnectReqIds(ConnectStatusType.Accepted);
     var filterUsers = users;
     if (_checkedItems.Contains(CONN) && !_checkedItems.Contains(N_CONN))
     {
         filterUsers = users.Where(u => connIds.Contains(u.UserId));
     }
     if (_checkedItems.Contains(N_CONN) && !_checkedItems.Contains(CONN))
     {
         filterUsers = users.Where(u => !connIds.Contains(u.UserId));
     }
     return filterUsers;
 }
        public override IEnumerable <User> Execute(IEnumerable <User> users)
        {
            if (!_checkedItems.Any())
            {
                return(users);
            }
            var connectSrv  = new ConnectService();
            var connIds     = connectSrv.GetConnectReqIds(ConnectStatusType.Accepted);
            var filterUsers = users;

            if (_checkedItems.Contains(CONN) && !_checkedItems.Contains(N_CONN))
            {
                filterUsers = users.Where(u => connIds.Contains(u.UserId));
            }
            if (_checkedItems.Contains(N_CONN) && !_checkedItems.Contains(CONN))
            {
                filterUsers = users.Where(u => !connIds.Contains(u.UserId));
            }
            return(filterUsers);
        }
        public override void ComposeFilters(IEnumerable<User> users)
        {
            MasterFilters = FilterItems;
            FilterItems = new List<FilterItem>();
            var connectSrv = new ConnectService();
            var connIds = connectSrv.GetConnectReqIds(ConnectStatusType.Accepted);
            var connUsers = users.Where(u => connIds.Contains(u.UserId))
                            .ToList();
            var cfItem = new FilterItem(_checkedItems.Contains(CONN))
            {
                Count = connUsers.Count,
                ValueText = CONN
            };
            FilterItems.Add(cfItem);

            var ncfItem = new FilterItem(_checkedItems.Contains(N_CONN))
            {
                Count = users.Count() - connUsers.Count,
                //Count = users.Count(u => !u.IsRelative()) - connUsers.Count,
                ValueText = N_CONN
            };
            FilterItems.Add(ncfItem);
            MasterFilters = FilterItems;
        }