예제 #1
0
        public ActionResult RejectFriendRequest(int userId)
        {
            FriendBL.RejectFriendRequest(UserID, userId);

            string userName = UserBL.GetAllUsersDO().First(q => q.ID == userId).Username;

            return(RedirectToAction("UserProfile", "User", new { username = userName }));
        }
예제 #2
0
        public ActionResult UserProfile(string username)
        {
            ProfileModel model = new ProfileModel();

            model.User  = UserBL.GetUserDOByUsername(username);
            model.IsYou = (model.User.ID == UserID);

            model.FriendStatus = FriendBL.GetFriendshipStatus(UserID, model.User.ID);

            return(View(model));
        }
예제 #3
0
        public ActionResult AddFriend(int userId)
        {
            UserFriendRequestDO requestDO = new UserFriendRequestDO();

            requestDO.RequestCreatorUserID = this.UserID;
            requestDO.RequestSentToUserID  = userId;
            requestDO.RequestStatus        = (int)FriendRequestStatusType.Requested;
            FriendBL.SendFriendRequest(requestDO);

            string userName = UserBL.GetAllUsersDO().First(q => q.ID == userId).Username;

            return(RedirectToAction("UserProfile", "User", new { username = userName }));
        }
예제 #4
0
        public GroupAndFriendResultModel GetContactList()
        {
            GroupAndFriendResultModel result = new GroupAndFriendResultModel();

            try
            {
                int?memberId = IdentityHelper.GetMemberId();
                if (!memberId.HasValue)
                {
                    throw new OrgException("Invalid member MemberId");
                }

                FriendBL friendBl = new FriendBL();

                var favouriteList = friendBl.GetFriends(memberId.Value, true, OrgComm.Data.Models.Friend.StatusType.Active);
                var friendList    = friendBl.GetFriends(memberId.Value, false, OrgComm.Data.Models.Friend.StatusType.Active);

                GroupBL groupBl = new GroupBL();

                var groupList = groupBl.GetGroupsByMember(memberId.Value, null);

                result.Status  = true;
                result.Message = ((friendList.Count + favouriteList.Count == 0) ? "No friend found." : (friendList.Count + favouriteList.Count).ToString() + " friends found. ")
                                 + ((groupList.Count == 0) ? "No group found." : groupList.Count.ToString() + " groups found.");

                result.Favourites = favouriteList;
                result.Friends    = friendList;
                result.Groups     = groupList;
            }
            catch (OrgException oex)
            {
                result.Status  = false;
                result.Message = oex.Message;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = AppConfigs.InternalErrorMessage;

                if (AppConfigs.DebugInternalMessage)
                {
                    result.InternalMessage = ex.Message;
                }
            }

            return(result);
        }
예제 #5
0
        public ResultModel SetBlock(FriendBlockRequestModel param)
        {
            ResultModel result = new ResultModel();

            try
            {
                int?memberId = IdentityHelper.GetMemberId();
                if (!memberId.HasValue)
                {
                    throw new OrgException("Invalid MemberId");
                }

                if (!param.FriendMemberId.HasValue)
                {
                    throw new OrgException("Invalid firend MemberId");
                }

                FriendBL bl = new FriendBL();

                bl.SetFriendStatus(memberId.Value, param.FriendMemberId.Value, (param.IsBlocked)? OrgComm.Data.Models.Friend.StatusType.Block : OrgComm.Data.Models.Friend.StatusType.Active);

                result.Status  = true;
                result.Message = "Update friend status successfully";
            }
            catch (OrgException oex)
            {
                result.Status  = false;
                result.Message = oex.Message;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = AppConfigs.InternalErrorMessage;

                if (AppConfigs.DebugInternalMessage)
                {
                    result.InternalMessage = ex.Message;
                }
            }

            return(result);
        }
예제 #6
0
        public FriendResultModel GetHiddenMember()
        {
            FriendResultModel result = new FriendResultModel();

            try
            {
                int?memberId = IdentityHelper.GetMemberId();
                if (!memberId.HasValue)
                {
                    throw new OrgException("Invalid member MemberId");
                }

                FriendBL friendBl = new FriendBL();

                var friendList = friendBl.GetFriends(memberId.Value, null, OrgComm.Data.Models.Friend.StatusType.Hide);

                result.Status  = true;
                result.Message = ((friendList.Count == 0) ? "No hidden-friend found." : friendList.Count.ToString() + " hiddend-friends found. ");
                result.Friends = friendList;
            }
            catch (OrgException oex)
            {
                result.Status  = false;
                result.Message = oex.Message;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = AppConfigs.InternalErrorMessage;

                if (AppConfigs.DebugInternalMessage)
                {
                    result.InternalMessage = ex.Message;
                }
            }

            return(result);
        }
예제 #7
0
        public ResultModel SetFavourite(FriendFavouriteRequestModel param)
        {
            ResultModel result = new ResultModel();

            try
            {
                int?memberId = IdentityHelper.GetMemberId();
                if (!memberId.HasValue)
                {
                    throw new OrgException("Invalid MemberId");
                }

                FriendBL bl = new FriendBL();

                bl.SetFavouriteFriend(memberId.Value, param);

                result.Status  = true;
                result.Message = "Update favorite friend successfully";
            }
            catch (OrgException oex)
            {
                result.Status  = false;
                result.Message = oex.Message;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = AppConfigs.InternalErrorMessage;

                if (AppConfigs.DebugInternalMessage)
                {
                    result.InternalMessage = ex.Message;
                }
            }

            return(result);
        }