Ejemplo n.º 1
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Validation.AssertAtLeastOne(this, M.RequestItem.Product, M.RequestItem.ProductFeature, M.RequestItem.SerialisedItem, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);
            derivation.Validation.AssertExistsAtMostOne(this, M.RequestItem.Product, M.RequestItem.ProductFeature, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);
            derivation.Validation.AssertExistsAtMostOne(this, M.RequestItem.SerialisedItem, M.RequestItem.ProductFeature, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);

            var requestItemStates = new RequestItemStates(derivation.Session);

            if (this.IsValid)
            {
                if (this.RequestWhereRequestItem.RequestState.IsSubmitted && this.RequestItemState.IsDraft)
                {
                    this.RequestItemState = requestItemStates.Submitted;
                }

                if (this.RequestWhereRequestItem.RequestState.IsCancelled)
                {
                    this.RequestItemState = requestItemStates.Cancelled;
                }

                if (this.RequestWhereRequestItem.RequestState.IsRejected)
                {
                    this.RequestItemState = requestItemStates.Rejected;
                }

                if (this.RequestWhereRequestItem.RequestState.IsQuoted)
                {
                    this.RequestItemState = requestItemStates.Quoted;
                }
            }

            if (!this.ExistUnitOfMeasure)
            {
                this.UnitOfMeasure = new UnitsOfMeasure(this.Strategy.Session).Piece;
            }

            if (this.ExistRequestWhereRequestItem && new RequestStates(this.Strategy.Session).Cancelled.Equals(this.RequestWhereRequestItem.RequestState))
            {
                this.Cancel();
            }

            if (this.ExistSerialisedItem && this.Quantity != 1)
            {
                derivation.Validation.AddError(this, this.Meta.Quantity, ErrorMessages.SerializedItemQuantity);
            }
        }
Ejemplo n.º 2
0
        protected override void AppsSecure(Security config)
        {
            base.AppsSecure(config);

            var draft     = new RequestItemStates(this.Session).Draft;
            var cancelled = new RequestItemStates(this.Session).Cancelled;
            var submitted = new RequestItemStates(this.Session).Submitted;
            var quoted    = new RequestItemStates(this.Session).Quoted;

            var cancel = this.Meta.Cancel;
            var hold   = this.Meta.Hold;
            var submit = this.Meta.Submit;
            var delete = this.Meta.Delete;

            config.Deny(this.ObjectType, submitted, submit);
            config.Deny(this.ObjectType, cancelled, cancel, submit, hold);
            config.Deny(this.ObjectType, quoted, cancel, submit, hold, delete);

            config.Deny(this.ObjectType, cancelled, Operations.Write);
            config.Deny(this.ObjectType, quoted, Operations.Write);
        }