コード例 #1
0
ファイル: Repository.cs プロジェクト: JoseMilhazes/DSS4
 public void DeleteApplicationPermission(zAppDev.DotNet.Framework.Identity.Model.ApplicationPermission applicationpermission, bool doNotCallDeleteForThis = false, bool isCascaded = false, object calledBy = null)
 {
     if (applicationpermission == null || applicationpermission.IsTransient())
     {
         return;
     }
     if (applicationpermission.Roles.Count > 0)
     {
         var cs = new System.Data.ConstraintException("applicationpermission.Roles elements are restricted and cannot be deleted");
         cs.Data["Entity"]       = "ApplicationPermission";
         cs.Data["PropertyName"] = "Roles";
         cs.Data["Multiplicity"] = "*";
         throw cs;
     }
     if (applicationpermission.Users.Count > 0)
     {
         var cs = new System.Data.ConstraintException("applicationpermission.Users elements are restricted and cannot be deleted");
         cs.Data["Entity"]       = "ApplicationPermission";
         cs.Data["PropertyName"] = "Users";
         cs.Data["Multiplicity"] = "*";
         throw cs;
     }
     foreach (var toDissasociate in applicationpermission.Operations)
     {
         applicationpermission.RemoveOperations(toDissasociate);
     }
     if (!doNotCallDeleteForThis)
     {
         Delete <zAppDev.DotNet.Framework.Identity.Model.ApplicationPermission>(applicationpermission, isCascaded);
     }
 }
コード例 #2
0
ファイル: Repository.cs プロジェクト: JoseMilhazes/DSS4
        public void DeleteProfile(zAppDev.DotNet.Framework.Identity.Model.Profile profile, bool doNotCallDeleteForThis = false, bool isCascaded = false, object calledBy = null)
        {
            if (profile == null || profile.IsTransient())
            {
                return;
            }
            foreach (var toDelete in profile.Settings)
            {
                profile.RemoveSettings(toDelete);
                DeleteProfileSetting(toDelete, false, isCascaded);
            }
            var _ApplicationUserApplicationUserProfilecount = this.Get <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(ap => ap.Profile == profile).Count;

            if (
                (calledBy != null)
                &&
                (
                    (calledBy.GetType() == typeof(zAppDev.DotNet.Framework.Identity.Model.ApplicationUser) || calledBy.GetType().FullName == "ApplicationUserProxy")
                )
                )
            {
                _ApplicationUserApplicationUserProfilecount--;
            }
            if (_ApplicationUserApplicationUserProfilecount > 0)
            {
                var cs = new System.Data.ConstraintException("At least one ApplicationUser exists so Profile cannot be deleted");
                cs.Data["Entity"]       = "ApplicationUser";
                cs.Data["PropertyName"] = "Profile";
                cs.Data["Multiplicity"] = "0..1";
                throw cs;
            }
            if (!doNotCallDeleteForThis)
            {
                Delete <zAppDev.DotNet.Framework.Identity.Model.Profile>(profile, isCascaded);
            }
        }