Exemplo n.º 1
0
        public override bool IsValid(params ILegalPerson[] persons)
        {
            var offeror = this.Offeror(persons);
            var offeree = this.Offeree(persons);

            if (offeree == null || offeror == null)
            {
                return(false);
            }

            if (Assent == null)
            {
                AddReasonEntry("There is no agreement.");
                return(false);
            }

            if (!Assent.IsValid(offeror, offeree))
            {
                AddReasonEntry("The agreement is invalid");
                AddReasonEntryRange(Assent.GetReasonEntries());
                return(false);
            }

            if (!IsEnforceableInCourt)
            {
                AddReasonEntry("The contract is not enforceable in court and is therefore void.");
                return(false);
            }

            if (Offer != null && Offer.IsValid(offeror, offeree) == false)
            {
                AddReasonEntry($"The {Offer.GetType().Name} is invalid");
                AddReasonEntryRange(Offer.GetReasonEntries());
                return(false);
            }

            if (Acceptance == null)
            {
                return(true);
            }

            var acceptance = Acceptance(Offer);

            if (acceptance != null && acceptance.IsValid(offeror, offeree) == false)
            {
                AddReasonEntry($"The {acceptance.GetType().Name} is invalid");
                AddReasonEntryRange(acceptance.GetReasonEntries());
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public override bool IsValid(params ILegalPerson[] persons)
        {
            var lessor = this.Lessor(persons);
            var lessee = this.Lessee(persons);

            if (lessor == null || lessee == null)
            {
                return(false);
            }

            var orTitle = lessor.GetLegalPersonTypeName();
            var eeTitle = lessee.GetLegalPersonTypeName();

            if (Inception == DateTime.MinValue)
            {
                AddReasonEntry($"{orTitle} {lessor.Name} and {eeTitle} {lessee.Name}, {nameof(Inception)} is unassigned");
                return(false);
            }

            if (Terminus != null && Terminus.Value <= Inception)
            {
                AddReasonEntry($"{orTitle} {lessor.Name} and {eeTitle} {lessee.Name}, {nameof(Terminus)} " +
                               $"date of {Terminus.Value.ToShortDateString()} is less-than-equal-to " +
                               $"the {nameof(Inception)} date of {Inception.ToShortDateString()}");
                return(false);
            }

            if (Assent != null && !Assent.IsValid(persons))
            {
                AddReasonEntryRange(Assent.GetReasonEntries());
                return(false);
            }

            if (SubjectProperty == null || Offer == null)
            {
                AddReasonEntry($"{orTitle} {lessor.Name} and {eeTitle} {lessee.Name}, " +
                               $"{nameof(SubjectProperty)} '{SubjectProperty?.Name}' " +
                               $"or {nameof(Offer)} '{Offer?.Name}' is unassigned");
                return(false);
            }

            if (Acceptance?.Invoke(Offer) == null)
            {
                AddReasonEntry($"{orTitle} {lessor.Name} and {eeTitle} {lessee.Name}, {nameof(Acceptance)} " +
                               $"using {nameof(Offer)} '{Offer.Name}' returned nothing");
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public override bool IsValid(params ILegalPerson[] persons)
        {
            var offeror = persons.Offeror();
            var offeree = persons.Offeree();

            if (!IsEnforceableInCourt)
            {
                AddReasonEntry("The contract is not enforceable in court and is therefore void.");
                return(false);
            }

            if (Consideration == null)
            {
                AddReasonEntry($"{nameof(Consideration)} is null");
                return(false);
            }

            if (!Consideration.IsValid(offeror, offeree))
            {
                AddReasonEntry($"{nameof(Consideration)}.{nameof(IsValid)} returned false");
                AddReasonEntryRange(Consideration.GetReasonEntries());
                return(false);
            }

            if (Offer == null)
            {
                AddReasonEntry($"{nameof(Offer)} is null");
                return(false);
            }

            if (!Offer.IsValid(offeror, offeree))
            {
                AddReasonEntry("the offer in invalid");
                AddReasonEntryRange(Offer.GetReasonEntries());
                return(false);
            }

            //short-circuit since this allows for no return promise
            var promissoryEstoppel = Consideration as PromissoryEstoppel <T>;

            if (promissoryEstoppel != null)
            {
                return(true);
            }

            if (!Offer.IsEnforceableInCourt)
            {
                AddReasonEntry("the offer is not enforceable in court");
                AddReasonEntryRange(Offer.GetReasonEntries());
                return(false);
            }

            if (Acceptance == null)
            {
                AddReasonEntry($"{nameof(Acceptance)} is null");
                return(false);
            }

            var returnPromise = Acceptance(Offer);

            if (returnPromise == null)
            {
                AddReasonEntry($"{nameof(returnPromise)} is null");
                return(false);
            }

            if (!returnPromise.IsEnforceableInCourt)
            {
                AddReasonEntry("the return promise is not enforceable in court");
                AddReasonEntryRange(returnPromise.GetReasonEntries());
                return(false);
            }

            if (!returnPromise.IsValid(offeror, offeree))
            {
                AddReasonEntry("the return promise is invalid");
                AddReasonEntryRange(returnPromise.GetReasonEntries());
                return(false);
            }

            if (Assent != null && !Assent.IsValid(offeror, offeree))
            {
                AddReasonEntry($"{nameof(Assent)}.{nameof(IsValid)} returned false");
                AddReasonEntryRange(Assent.GetReasonEntries());
                return(false);
            }

            return(true);
        }