Esempio n. 1
0
        public async Task <IEnumerable <FriendListModel> > GetAllRequestsOutgoingAsync(int userId)
        {
            IEnumerable <FriendsListJunctionModel> junctionModel = await _userInteractionService.GetAllUserFriendRequestsOutgoing(userId);

            List <FriendListModel> friendListModel = new List <FriendListModel>();

            foreach (var junction in junctionModel)
            {
                FriendListModel model = new FriendListModel();
                if (userId == junction.User1Id)
                {
                    model.userId = junction.User2Id;
                }
                else
                {
                    model.userId = junction.User1Id;
                }

                PublicUserProfileModel publicUserProfileModel = await _publicUserProfileService.GetUserProfileAsync(model.userId);

                model.userProfileImage = publicUserProfileModel.Photo;
                UserAccountModel userAccount = await _userAccountRepository.GetAccountById(model.userId);

                model.username = userAccount.Username;
                model.date     = DateTime.UtcNow;
                model.status   = publicUserProfileModel.Status;

                friendListModel.Add(model);
            }

            return(friendListModel);
        }
Esempio n. 2
0
 private void OnThisUserStateChanged(FriendListModel model)
 {
     while (!this.IsHandleCreated)
     {
         ;
     }
     if (this.InvokeRequired)
     {
         this.Invoke((FriendListController.ExternalEventHandler)
                     OnThisUserStateChanged, model);
         return;
     }
     if (LoggedInUserModel.Instance.User.Status)
     {
         toggleStatusButton.Text      = "Go Offline";
         panel1.Visible               = true;
         addFriendTextBox.Visible     = true;
         customStylesCheckbox.Visible = true;
         offlineCheckBox.Visible      = true;
         invitingCheckBox.Visible     = true;
         invitedCheckBox.Visible      = true;
     }
     else
     {
         toggleStatusButton.Text      = "Go Online";
         panel1.Visible               = false;
         addFriendTextBox.Visible     = false;
         customStylesCheckbox.Visible = false;
         offlineCheckBox.Visible      = false;
         invitingCheckBox.Visible     = false;
         invitedCheckBox.Visible      = false;
     }
 }
Esempio n. 3
0
 public btnInviteClick(FriendListModel friendListModel, Activity context, long eventID, Contact_FriendAdapter objContact_FriendAdapter)
 {
     this.friendListModel          = friendListModel;
     this.context                  = context;
     this.eventID                  = eventID;
     this.objContact_FriendAdapter = objContact_FriendAdapter;
 }
        public postEventRequest(FriendListModel objFLM, Activity context, long eventID, Contact_FriendAdapter objContact_FriendAdapter)
        {
            this.objFLM  = objFLM;
            this.context = context;
            this.eventID = eventID;
            this.objContact_FriendAdapter = objContact_FriendAdapter;

            if (objFLM.IsEmail == true)
            {
                this.eventRequestModel = new EventRequest
                {
                    EventID  = eventID,
                    FriendID = objFLM.ID,
                    Email    = objFLM.PhoneNumber,
                };
            }
            else
            {
                this.eventRequestModel = new EventRequest
                {
                    EventID     = eventID,
                    FriendID    = objFLM.ID,
                    PhoneNumber = objFLM.PhoneNumber,
                };
            }
        }
Esempio n. 5
0
        public async Task <IEnumerable <FriendListModel> > GetMutualFriends(int userId1, int userId2)
        {
            IEnumerable <FriendsListJunctionModel> junctionModel1 = await _userInteractionService.GetAllUserFriends(userId1);



            IEnumerable <FriendsListJunctionModel> junctionModel2 = await _userInteractionService.GetAllUserFriends(userId2);

            List <FriendsListJunctionModel> junctionModel = new List <FriendsListJunctionModel>();


            foreach (var user1 in junctionModel1)
            {
                foreach (var user2 in junctionModel2)
                {
                    if (user1.User2Id == user2.User2Id)
                    {
                        junctionModel.Add(user1);
                    }
                    if (user1.User1Id == user2.User2Id)
                    {
                        junctionModel.Add(user1);
                    }
                    if (user1.User2Id == user2.User1Id)
                    {
                        junctionModel.Add(user1);
                    }
                }
            }

            List <FriendListModel> friendListModel = new List <FriendListModel>();

            foreach (var junction in junctionModel)
            {
                if ((junction.User1Id != userId1 && junction.User2Id != userId2) || (junction.User2Id != userId1 && junction.User1Id != userId2))
                {
                    FriendListModel model = new FriendListModel();
                    model.userId = junction.User2Id;


                    UserAccountModel userAccount = await _userAccountRepository.GetAccountById(model.userId);

                    PublicUserProfileModel publicUserProfileModel = await _publicUserProfileService.GetUserProfileAsync(model.userId);

                    model.userProfileImage = publicUserProfileModel.Photo;
                    model.username         = userAccount.Username;
                    model.date             = DateTime.UtcNow;
                    model.status           = publicUserProfileModel.Status;

                    if (model.userId != userId1 && model.userId != userId2)
                    {
                        friendListModel.Add(model);
                    }
                }
            }

            return(friendListModel);
        }
Esempio n. 6
0
    public static FriendListModel GenerateFriendList(IEnumerable <FriendEntity> entities)
    {
        var modelList = new List <FriendModel>();

        foreach (var entity in entities)
        {
            var model = new FriendModel(entity);
            modelList.Add(model);
        }

        var listModel = new FriendListModel();

        listModel.friends = modelList;

        return(listModel);
    }
Esempio n. 7
0
        public JsonResult AcceptFriendRequest(int id)
        {
            RequestModel reqModel = requestRepository.Get(id);

            FriendListModel friendListModel = new FriendListModel
            {
                UserId   = reqModel.RequestToId,
                FriendId = reqModel.RequestFromId
            };

            friendRepository.Add(friendListModel);
            friendRepository.Save();

            requestRepository.Remove(id);
            requestRepository.Save();
            return(Json(new { Result = true }));
        }
    public void SetFriendListModel(FriendListModel model)
    {
        this.friends = model.friends;

        float lastY = this.friendCellBase.rectTransform.anchoredPosition.y;

        foreach (var friend in model.friends)
        {
            var obj = GameObject.Instantiate <GameObject>(friendCellBase.gameObject);
            obj.SetActive(true);

            var nameText = obj.GetComponent <Text>();
            nameText.text = friend.name;

            obj.transform.SetParent(this.friendCellBase.transform.parent, false);
            obj.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, lastY, 0);
            lastY += 30;
        }
    }
Esempio n. 9
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <FriendListModel> FriendsToList(DataTable dt)
        {
            List <FriendListModel> modelList = new List <FriendListModel>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                FriendListModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model            = new FriendListModel();
                    model.UserID     = dt.Rows[n]["UserID"] == null ? "" : dt.Rows[n]["UserID"].ToString();
                    model.FriendCode = dt.Rows[n]["FriendCode"] == null ? "" : dt.Rows[n]["FriendCode"].ToString();
                    model.Pic        =
                        dt.Rows[n]["Pic"] == null || dt.Rows[n]["Pic"].ToString() == "" ? "" : WebHelper.HttpDomain + dt.Rows[n]["Pic"].ToString();
                    model.NiceName = dt.Rows[n]["NiceName"] == null ? "" : dt.Rows[n]["NiceName"].ToString();
                    model.PhoneNum = dt.Rows[n]["PhoneNum"] == null ? "" : dt.Rows[n]["PhoneNum"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
 public void DidLoadFriendList(FriendListModel model)
 {
     this.viewController.SetFriendListModel(model);
 }
Esempio n. 11
0
        private void PutUserOnList(uint thisUserId, int index, UserData user, FriendListModel model, bool friendshipStatus, bool onlineStatus)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FriendListView));
            PictureBox icon = new PictureBox();

            ((System.ComponentModel.ISupportInitialize)(icon)).BeginInit();
            if (!friendshipStatus)
            {
                icon.Image = global::REACH.Client.Properties.Resources.user_pending;
            }
            else if (onlineStatus)
            {
                icon.Image = global::REACH.Client.Properties.Resources.user_online;
            }
            else
            {
                icon.Image = global::REACH.Client.Properties.Resources.user_offline;
            }
            icon.Location = new Point(lineHeight - 20, index * lineHeight + 2);
            icon.Size     = new Size(20, 20);
            panel1.Controls.Add(icon);

            FriendshipData friendship = model.GetFriendshipById(user.Id);

            if (!(friendship.Status))
            {
                if (friendship.Latter == thisUserId)
                {
                    Button acceptButton = new Button();
                    acceptButton.Text     = "accept";
                    acceptButton.Location = new Point(130, index * lineHeight);
                    acceptButton.Size     = new Size(80, lineHeight);
                    acceptButton.AutoSize = false;
                    acceptButton.Click   += new System.EventHandler(this.OnAccept);
                    acceptButtons.Add(acceptButton, user.Id);
                    panel1.Controls.Add(acceptButton);

                    Button denyButton = new Button();
                    denyButton.Text     = "deny";
                    denyButton.Location = new Point(210, index * lineHeight);
                    denyButton.Size     = new Size(80, lineHeight);
                    denyButton.AutoSize = false;
                    denyButton.Click   += new System.EventHandler(this.OnDeny);
                    denyButtons.Add(denyButton, user.Id);
                    panel1.Controls.Add(denyButton);
                }
            }

            Label friendname = new Label();

            friendname.Text     = user.Username;
            friendname.Location = new Point(30, index * lineHeight);
            friendname.Font     = new Font(
                "Microsoft Sans Serif",
                9.75F,
                FontStyle.Regular,
                GraphicsUnit.Point, ((byte)(0)));
            friendname.AutoSize    = false;
            friendname.Size        = new Size(panel1.Width - 55, lineHeight);
            friendname.Click      += new System.EventHandler(this.OnNameClick);
            friendname.MouseEnter += new System.EventHandler(this.ColorNameLabel);
            friendname.MouseLeave += new System.EventHandler(this.UncolorNameLabel);
            nameLabels.Add(friendname, user.Id);
            panel1.Controls.Add(friendname);
        }
Esempio n. 12
0
        /*
         * Handlers for external events
         */
        #region external_events

        private void OnFriendListStateChanged(FriendListModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((FriendListController.ExternalEventHandler)
                            OnFriendListStateChanged, model);
                return;
            }
            nameLabels.Clear();
            denyButtons.Clear();
            acceptButtons.Clear();
            uint thisUserId = LoggedInUserModel.Instance.User.Id;
            int  index      = 0;

            panel1.Controls.Clear();
            panel1.Focus();
            panel1.SuspendLayout();
            // Online users
            foreach (UserData user in model.Users)
            {
                FriendshipData friendship = model.GetFriendshipById(user.Id);
                if (friendship.Status && user.Status)
                {
                    PutUserOnList(thisUserId, index++, user, model, friendship.Status, user.Status);
                }
            }
            // Offline users
            if (offlineCheckBox.Checked)
            {
                foreach (UserData user in model.Users)
                {
                    FriendshipData friendship = model.GetFriendshipById(user.Id);
                    if (friendship.Status && !user.Status)
                    {
                        PutUserOnList(thisUserId, index++, user, model, friendship.Status, user.Status);
                    }
                }
            }
            // Inviting users
            if (invitingCheckBox.Checked)
            {
                foreach (UserData user in model.Users)
                {
                    FriendshipData friendship = model.GetFriendshipById(user.Id);
                    if (!friendship.Status && friendship.Latter == thisUserId)
                    {
                        PutUserOnList(thisUserId, index++, user, model, friendship.Status, user.Status);
                    }
                }
            }
            // Invited users
            if (invitedCheckBox.Checked)
            {
                foreach (UserData user in model.Users)
                {
                    FriendshipData friendship = model.GetFriendshipById(user.Id);
                    if (!friendship.Status && friendship.Latter != thisUserId)
                    {
                        PutUserOnList(thisUserId, index++, user, model, friendship.Status, user.Status);
                    }
                }
            }
            panel1.ResumeLayout();
            panel1.PerformLayout();
        }