public virtual void InternalRemoveOperations(ApplicationOperation __item)
 {
     if (__item == null)
     {
         return;
     }
     operations?.Remove(__item);
 }
 public virtual void InternalAddOperations(ApplicationOperation __item)
 {
     if (__item == null || disableInternalAdditions)
     {
         return;
     }
     operations?.Add(__item);
 }
 public virtual void RemoveOperations(ApplicationOperation __item)
 {
     if (__item != null)
     {
         if (operations.Contains(__item))
         {
             InternalRemoveOperations(__item);
         }
         if (__item.Permissions.Contains(this))
         {
             __item.RemovePermissions(this);
         }
     }
 }
 public virtual void SetOperationsAt(ApplicationOperation __item, int __index)
 {
     if (__item == null)
     {
         operations[__index].RemovePermissions(this);
     }
     else
     {
         operations[__index] = __item;
         if (!__item.Permissions.Contains(this))
         {
             __item.AddPermissions(this);
         }
     }
 }
 public virtual void AddAtIndexOperations(int index, ApplicationOperation __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!operations.Contains(__item))
     {
         operations.Insert(index, __item);
     }
     if (!__item.Permissions.Contains(this))
     {
         __item.AddPermissions(this);
     }
 }
 public virtual void AddOperations(ApplicationOperation __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!operations.Contains(__item))
     {
         InternalAddOperations(__item);
     }
     if (!__item.Permissions.Contains(this))
     {
         __item.AddPermissions(this);
     }
 }
Exemplo n.º 7
0
 public void DeleteApplicationOperation(zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation applicationoperation, bool doNotCallDeleteForThis = false, bool isCascaded = false, object calledBy = null)
 {
     if (applicationoperation == null || applicationoperation.IsTransient())
     {
         return;
     }
     if (applicationoperation.Permissions.Count > 0)
     {
         var cs = new System.Data.ConstraintException("applicationoperation.Permissions elements are restricted and cannot be deleted");
         cs.Data["Entity"]       = "ApplicationOperation";
         cs.Data["PropertyName"] = "Permissions";
         cs.Data["Multiplicity"] = "*";
         throw cs;
     }
     if (!doNotCallDeleteForThis)
     {
         Delete <zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation>(applicationoperation, 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(ApplicationOperation compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
/// <summary>
/// Copies the current object to a new instance
/// </summary>
/// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param>
/// <param name="copiedObjects">Objects that should be reused</param>
/// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param>
/// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param>
/// <param name="copy">Optional - An existing [ApplicationOperation] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual ApplicationOperation Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, ApplicationOperation copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((ApplicationOperation)copiedObjects[this]);
            }
            copy = copy ?? new ApplicationOperation();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Name = this.Name;
            copy.ParentControllerName = this.ParentControllerName;
            copy.Type = this.Type;
            copy.IsAvailableToAnonymous          = this.IsAvailableToAnonymous;
            copy.IsAvailableToAllAuthorizedUsers = this.IsAvailableToAllAuthorizedUsers;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            copy.permissions = new List <ApplicationPermission>();
            if (deep && this.permissions != null)
            {
                foreach (var __item in this.permissions)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddPermissions(__item);
                        }
                        else
                        {
                            copy.AddPermissions(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddPermissions((ApplicationPermission)copiedObjects[__item]);
                    }
                }
            }
            return(copy);
        }