Ejemplo n.º 1
0
        public CompatibilityModel CalculateCompatibility(PersonModel personModel1, PersonModel personModel2, bool isHideSexuality)
        {
            var nineStarKiModel1 = CalculateNineStarKiProfile(personModel1, true);
            var nineStarKiModel2 = CalculateNineStarKiProfile(personModel2, true);

            var model = new CompatibilityModel(nineStarKiModel1, nineStarKiModel2)
            {
                IsProcessed = true,
                IsUpgradeRequired = true,
                IsHideSexualChemistry = isHideSexuality
            };

            if (_authentication.IsAuthenticated)
            {
                if (_roles.CurrentUserIsInRoles(RoleNames.Administrators) ||
                    _membershipService.IsCompleteRelationshipCompatibilityReading(_authentication.CurrentUserId,
                        personModel1, personModel2, isHideSexuality))
                {
                    model.IsUpgradeRequired = false;
                }
            }

            return model;
        }
        private bool CheckRole(IRoles roles, string roleName, IAuthentication authentication)
        {
            var userRoles = roles.GetRolesForCurrentUser().Select(r => r.Name).ToList();

            if ((!authentication.IsAuthenticated || !userRoles.Contains(roleName)) && !roles.CurrentUserIsInRoles(RoleNames.Administrators))
            {
                return(false);
            }

            return(true);
        }
        private bool CheckPermission(IRoles roles, string permissionName, IAuthentication authentication)
        {
            var permissions = roles.GetPermissionsForCurrentUser().Select(r => r.Name).ToList();

            if ((!authentication.IsAuthenticated || !permissions.Contains(permissionName)) && !roles.CurrentUserIsInRoles(RoleNames.Administrators))
            {
                return(false);
            }
            return(true);
        }