Пример #1
0
        //NOTE - SetCompanyButtons, SetBranchButtons, SetUserButtons, must run in that order as the user rely on the branch rely on the company
        //There is also a check on block as if Block is set then no buttons should be shown for that level downwards.
        public static ViewButtons SetCompanyButtons(ApplicationDbContext db, ViewButtons buttons, Guid viewItemcompanyId, Guid currentCompanyId)
        {
            buttons.CompanyBlockButton = !BlockHelpers.IsReferenceBlocked(db, LevelEnum.Company, viewItemcompanyId, currentCompanyId);

            //if company block then do not show company and lower add buttons
            if (!buttons.CompanyBlockButton)
            {
                buttons.CompanyAddFriendButton  = buttons.CompanyBlockButton;
                buttons.CompanyAddToGroupButton = buttons.CompanyBlockButton;
            }
            else
            {
                buttons.CompanyAddFriendButton  = !FriendHelpers.IsReferenceAnActiveFriendRequest(db, LevelEnum.Company, viewItemcompanyId, currentCompanyId);
                buttons.CompanyAddToGroupButton = !GroupHelpers.IsReferenceInGroup(db, LevelEnum.Company, viewItemcompanyId, currentCompanyId);
            }
            return(buttons);
        }
Пример #2
0
        public static ViewButtons SetUserButtons(ApplicationDbContext db, ViewButtons buttons, Guid viewItemUserId, Guid currentUserId)
        {
            //if the button is hidden at branch level then hide at user level
            if (!buttons.BranchBlockButton)
            {
                buttons.UserBlockButton = buttons.BranchBlockButton;
            }
            else
            {
                buttons.UserBlockButton = !BlockHelpers.IsReferenceBlocked(db, LevelEnum.User, viewItemUserId, currentUserId);
            }

            //If user block then do not show user buttons
            if (!buttons.UserBlockButton)
            {
                buttons.UserAddFriendButton  = buttons.UserBlockButton;
                buttons.UserAddToGroupButton = buttons.UserBlockButton;
            }
            else
            {
                if (!buttons.BranchAddFriendButton)
                {
                    buttons.UserAddFriendButton = buttons.BranchAddFriendButton;
                }
                else
                {
                    buttons.UserAddFriendButton = !FriendHelpers.IsReferenceAnActiveFriendRequest(db, LevelEnum.User, viewItemUserId, currentUserId);
                }

                if (!buttons.BranchAddToGroupButton)
                {
                    buttons.UserAddToGroupButton = buttons.BranchAddToGroupButton;
                }
                else
                {
                    buttons.UserAddToGroupButton = !GroupHelpers.IsReferenceInGroup(db, LevelEnum.User, viewItemUserId, currentUserId);
                }
            }
            return(buttons);
        }
Пример #3
0
        public static ViewButtons SetBranchButtons(ApplicationDbContext db, ViewButtons buttons, Guid viewItemBranchId, Guid currentBranchId)
        {
            //if the button is hidden at company level then hide at branch level
            if (!buttons.CompanyBlockButton)
            {
                buttons.BranchBlockButton = buttons.CompanyBlockButton;
            }
            else
            {
                buttons.BranchBlockButton = !BlockHelpers.IsReferenceBlocked(db, LevelEnum.Branch, viewItemBranchId, currentBranchId);
            }

            //if branch block then do not show branch and lower add buttons
            if (!buttons.BranchBlockButton)
            {
                buttons.BranchAddFriendButton  = buttons.BranchBlockButton;
                buttons.BranchAddToGroupButton = buttons.BranchBlockButton;
            }
            else
            {
                if (!buttons.CompanyAddFriendButton)
                {
                    buttons.BranchAddFriendButton = buttons.CompanyAddFriendButton;
                }
                else
                {
                    buttons.BranchAddFriendButton = !FriendHelpers.IsReferenceAnActiveFriendRequest(db, LevelEnum.Branch, viewItemBranchId, currentBranchId);
                }

                if (!buttons.CompanyAddToGroupButton)
                {
                    buttons.BranchAddToGroupButton = buttons.CompanyAddToGroupButton;
                }
                else
                {
                    buttons.BranchAddToGroupButton = !GroupHelpers.IsReferenceInGroup(db, LevelEnum.Branch, viewItemBranchId, currentBranchId);
                }
            }
            return(buttons);
        }