示例#1
0
        public Permission GetPermission(PermissionSettings permissionSettings)
        {
            var rules = new List <IPermissionRule>();

            switch (permissionSettings.Action)
            {
            case ActionEnum.MenuViewProperty:
            case ActionEnum.ShareProperty:
            case ActionEnum.MenuAskQuestion:
            case ActionEnum.MenuReplyQuestion:
            case ActionEnum.ContextMenuMoreInformation:
            case ActionEnum.MenuAddFavourites:
            case ActionEnum.MessageToAgent:
            case ActionEnum.ViewPhoneCallOfAgent:
            case ActionEnum.DownloadBrochure:
            case ActionEnum.ViewLocation:
            case ActionEnum.RequestEnergyLabel:
            case ActionEnum.Request360Video:
                return(new NoRestriction());

            case ActionEnum.SendingDocuments:
            case ActionEnum.MenuScheduleViewing:
                rules.Add(this.propertyStatusRule);
                rules.Add(this.costumerPermissionRule);
                break;

            case ActionEnum.AddPhoto:
                rules.Add(this.propertyStatusRule);
                break;

            case ActionEnum.DeleteProperty:
            case ActionEnum.CheckBiddingStatus:
                rules.Add(this.privatePermissionRule);
                rules.Add(this.propertyStatusRule);
                rules.Add(this.costumerPermissionRule);
                break;

            case ActionEnum.ChangeBiddingPrice:
            case ActionEnum.MakeOffer:
                rules.Add(this.privatePermissionRule);
                rules.Add(this.propertyStatusRule);
                rules.Add(this.costumerPermissionRule);
                rules.Add(this.biddingLockedPermissionRule);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(permissionSettings.Action), permissionSettings.Action, "Action enum is out of range");
            }

            return(new RestrictedPermission(permissionSettings, rules));
        }
示例#2
0
        internal PermissionSettings GetPermissionSettings(CallContext cc)
        {
            var property           = this.propertyService.GetPropertyById(cc.PropertyId);
            var permissionSettings = new PermissionSettings()
            {
                IsPrivate            = cc.IsPrivate,
                PropertyStatusTypeId = property.StatusId,
                CallContext          = cc,
                PrivilegesByUserRoom = this.authorizationService.GetPrivilegesByUserProperty(cc.LoginName, cc.PropertyId,
                                                                                             PrivilegeCategoryEnum.All),
                IsBiddingLocked = property.IsBiddingLocked.GetValueOrDefault()
            };

            return(permissionSettings);
        }
示例#3
0
        private PermissionModel CreatePermissionModel(PermissionSettings permissionSettings)
        {
            var permission = this.permissionFactory.GetPermission(permissionSettings);

            if (permission is RestrictedPermission)
            {
                var restrictedPermission = (RestrictedPermission)permission;
                restrictedPermission.ApplyRules();
            }

            var permissionModel = new PermissionModel
            {
                Action    = permissionSettings.Action,
                IsEnabled = permission.IsEnabled,
                IsVisible = permission.IsVisible
            };

            return(permissionModel);
        }