Beispiel #1
0
 public void DeleteApplicationUser(zAppDev.DotNet.Framework.Identity.Model.ApplicationUser applicationuser, bool doNotCallDeleteForThis = false, bool isCascaded = false, object calledBy = null)
 {
     if (applicationuser == null || applicationuser.IsTransient())
     {
         return;
     }
     foreach (var toDelete in applicationuser.Clients)
     {
         applicationuser.RemoveClients(toDelete);
         DeleteApplicationClient(toDelete, false, isCascaded);
     }
     foreach (var toDelete in applicationuser.Logins)
     {
         applicationuser.RemoveLogins(toDelete);
         DeleteApplicationUserLogin(toDelete, false, isCascaded);
     }
     foreach (var toDelete in applicationuser.Claims)
     {
         applicationuser.RemoveClaims(toDelete);
         DeleteApplicationUserClaim(toDelete, false, isCascaded);
     }
     foreach (var toDissasociate in applicationuser.Permissions)
     {
         applicationuser.RemovePermissions(toDissasociate);
     }
     if (applicationuser.Profile != null)
     {
         var toDelete = applicationuser.Profile;
         applicationuser.Profile = null;
         DeleteProfile(toDelete, false, isCascaded, applicationuser);
     }
     foreach (var toDissasociate in applicationuser.Roles)
     {
         applicationuser.RemoveRoles(toDissasociate);
     }
     if (!doNotCallDeleteForThis)
     {
         Delete <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(applicationuser, isCascaded);
     }
 }
/// <summary>
///     Returns true if self and the provided entity have the same Id values
///     and the Ids are not of the default Id value
/// </summary>
        protected bool HasSameNonDefaultIdAs(ApplicationUser compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.UserName.Equals(compareTo.UserName));
        }