Example #1
0
        public ActionResult Contact(string accountId)
        {
            List <Account> friends         = friendshipService.GetAllFriend();
            List <Account> pendingFriends  = friendshipService.GetPendingFriendRequests();
            List <Account> classmates      = accountService.GetObjectList(0, 0, x => x.SchoolId == Account.SchoolId && x.ClassId == Account.ClassId, x => x.Id, Core.Enums.OrderingType.Ascending);
            Account        currentAccount  = accountId.IsNullOrEmpty() ? null : accountService.GetObject(Int64.Parse(accountId));
            List <Group>   groups          = currentAccount == null ? null : StructureMap.ObjectFactory.GetInstance <IGroupService>().GetGroups(currentAccount.Id);
            bool           isClassmate     = currentAccount == null ? false : currentAccount.SchoolId == Account.SchoolId && currentAccount.ClassId == Account.ClassId;
            bool           isSelf          = currentAccount == null ? false : currentAccount.Id == Account.Id;
            bool           isFriend        = currentAccount == null ? false : friends.Where(x => x.Id == currentAccount.Id).FirstOrDefault() != null;
            bool           isPendingFriend = currentAccount == null ? false : friendshipService.GetSentButNotAcceptedFriendRequests()
                                             .Where(x => x.Id == currentAccount.Id).FirstOrDefault() != null;

            return(View(new ContactViewModel()
            {
                Account = Account,
                MessagerList = new List <Messager>(),
                Friends = friends,
                PendingFriends = pendingFriends,
                Classmates = classmates,
                CurrentAccount = currentAccount,
                IsClassmate = isClassmate,
                IsSelf = isSelf,
                IsFriend = isFriend,
                IsPendingFriend = isPendingFriend,
                Groups = groups
            }));
        }