public void SetACLs(PurchaseLine _PurchaseLine, Services.Packages.Security.PurchaseLineAccessControlListCollection _ACLs, string SessionToken)
        {
            _PurchaseLine.Reload();

            //*
            if (!Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Traverse"))
                throw new UnauthorizedAccessException("Access Denied");
            //*/

            /*
            _ACLs.Reload();
            if (_ACLs.Exists && !Services.Packages.Security.Security.PurchaseLineAccessControlListSecureService.CheckAccessImp(_ACLs, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");
            else if (!_ACLs.Exists && !Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Create ACLs"))
                throw new UnauthorizedAccessException("Access Denied");
            //*/

            _PurchaseLine.ACLs = _ACLs;
            _PurchaseLine.Update();
        }
            public void SetOwner(PurchaseLine _PurchaseLine, Services.Packages.Security.ModelUser _Owner, string SessionToken)
            {
                _PurchaseLine.Reload();

                //*
                if (!Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Traverse"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                //*
                _Owner.Reload();
                if (_Owner.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_Owner, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");
                else if (!_Owner.Exists && !Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Create PurchaseLineOwning"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                _PurchaseLine.Owner = _Owner;
                _PurchaseLine.Update();
            }
        public PurchaseLine CreateFromPurchaseOrder(System.Int32 __Id, Services.Packages.Purchase _PurchaseOrder, string SessionToken)
        {
            ModelSession session = PurchaseLineSecureService.CheckSessionImp(SessionToken);

            PurchaseLine _PurchaseLine = new PurchaseLine(__Id);

            if (!_PurchaseLine.Exists && !Services.Packages.Security.PurchaseSecureService.CheckAccessImp(_PurchaseOrder, SessionToken, "Create OrderLines"))
                throw new UnauthorizedAccessException("Access Denied");
            else if (_PurchaseLine.Exists && !PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");

            // PurchaseLine _PurchaseLine = PurchaseLine.CreatePurchaseLine(__Id);
            _PurchaseLine.Owner = session.User;
            _PurchaseLine.PurchaseOrder = _PurchaseOrder;
            _PurchaseLine.Update();
            return _PurchaseLine;
        }
            public void UpdateObject(PurchaseLine _PurchaseLine, string SessionToken)
            {
                if (!PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");

                _PurchaseLine.Update();
            }