Ejemplo n.º 1
0
        public void Update(ProviderResponseScheme response, AccountSession accountSession)
        {
            if (this.Agreement.HasChanged(response.Agreement))
            {
                this.Agreement.Update(response.Agreement);
                this.Agreement.Receipt = new ChangeReceipt(accountSession);
            }

            if (this.Alternate.HasChanged(response.Alternate))
            {
                this.Alternate.Update(response.Alternate);
                this.Alternate.Receipt = new ChangeReceipt(accountSession);
            }
        }
Ejemplo n.º 2
0
        public static IRuleBuilderOptions <T, AgreementTypes> HasAgreementText <T>(this IRuleBuilder <T, AgreementTypes> rule, ProviderResponseScheme response, string propertyName)
        {
            return(rule.Must(value =>
            {
                using (var db = new MongoDbContext())
                {
                    var agreement = response.Agreement.ServicePreferences;
                    var alternate = response.Alternate.ServicePreferences;
                    var preference = (db.GetConsumerPortfolio(response.ConsumerPortfolioId)).Preference;
                    var preferenceValue = preference.ServicePreferences;

                    // check to see if the consumer has actually specified a value for this property
                    if (!string.IsNullOrEmpty(preferenceValue))
                    {
                        // has the provider selected a value for the agreement?
                        if (agreement == AgreementTypes.NA)
                        {
                            return false;
                        }

                        // check to see if the provider has decided to select an alternate value
                        if (agreement == AgreementTypes.Alternate)
                        {
                            // the provider has not chosen a valid alternate value
                            if (alternate.Value == GenericTypes.NA)
                            {
                                return false;
                            }

                            // check to see if the provider has added a valid alternate user defined value
                            if (alternate.Value == GenericTypes.UserSpecified)
                            {
                                return !string.IsNullOrEmpty(Convert.ToString(alternate.Specified));
                            }
                        }
                    }

                    return true;
                }
            }));
        }
Ejemplo n.º 3
0
        public static IRuleBuilderOptions <T, AgreementTypes> HasAgreementDate <T>(this IRuleBuilder <T, AgreementTypes> rule, ProviderResponseScheme response, string propertyName)
        {
            return(rule.Must(value =>
            {
                using (var db = new MongoDbContext())
                {
                    var agreement = (propertyName == "WakeDate" ? response.Agreement.WakeDate : response.Agreement.CeremonyDate);
                    var alternate = (propertyName == "WakeDate" ? response.Alternate.WakeDate : response.Alternate.CeremonyDate);
                    var schedule = (db.GetConsumerPortfolio(response.ConsumerPortfolioId)).Schedule;
                    var scheduleValue = (propertyName == "WakeDate" ? schedule.WakeDate : schedule.CeremonyDate);

                    // check to see if the consumer has actually specified a value for this property
                    if (scheduleValue.HasValue)
                    {
                        // has the provider selected a value for the agreement?
                        if (agreement == AgreementTypes.NA)
                        {
                            return false;
                        }

                        // check to see if the provider has decided to select an alternate value
                        if (agreement == AgreementTypes.Alternate)
                        {
                            // the provider has not chosen a valid alternate value
                            if (alternate.Value == GenericTypes.NA)
                            {
                                return false;
                            }

                            // check to see if the provider has added a valid alternate user defined value
                            if (alternate.Value == GenericTypes.UserSpecified)
                            {
                                // is this a valid date?
                                var outDate = new DateTime();
                                var result = DateTime.TryParse(Convert.ToString(alternate.Specified), out outDate);
                                return result;
                            }
                        }
                    }

                    return true;
                }
            }));
        }
 public static IRuleBuilderOptions <T, string> IsCurrentResponse <T>(this IRuleBuilder <T, string> rule, ProviderResponseScheme instance)
 {
     return(rule.Must(id =>
     {
         using (var db = new MongoDbContext())
         {
             var response = db.GetResponseById(id);
             if (response != null)
             {
                 // verify the current timestamps match
                 if (instance.Current.On == response.Current.On)
                 {
                     return true;
                 }
             }
         }
         return false;
     }));
 }
        public ResponseAgreementValidator(AccountSession accountSession, ValidationMode validationMode, ProviderResponseScheme response)
            : base(accountSession, validationMode)
        {
            #region Wake Date
            RuleFor(i => i.WakeDate)
            .HasAgreementDate(response, "WakeDate")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Wake Date must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Ceremony Date
            RuleFor(i => i.CeremonyDate)
            .HasAgreementDate(response, "CeremonyDate")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Funeral Date must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Internment Type
            RuleFor(i => i.InternmentType)
            .HasAgreement(response, "InternmentType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Internment must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Funeral Type
            RuleFor(i => i.FuneralType)
            .HasAgreement(response, "FuneralType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Funeral Style must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Wake Type
            RuleFor(i => i.WakeType)
            .HasAgreement(response, "WakeType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Wake Style must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Religion Type
            RuleFor(i => i.ReligionType)
            .HasAgreement(response, "ReligionType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Religion must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Expected Attendance Type
            RuleFor(i => i.ExpectedAttendanceType)
            .HasAgreement(response, "ExpectedAttendanceType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Expected attendance must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Service Preferences
            RuleFor(i => i.ServicePreferences)
            .HasAgreementText(response, "ServicePreferences")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Service Preferences must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Casket Material Type
            RuleFor(i => i.CasketMaterialType)
            .HasAgreement(response, "CasketMaterialType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Casket Material must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Casket Size Type
            RuleFor(i => i.CasketSizeType)
            .HasAgreement(response, "CasketSizeType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Casket Size must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Casket Color Type
            RuleFor(i => i.CasketColorType)
            .HasAgreement(response, "CasketColorType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Casket Color must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Casket Manufacturer Type
            RuleFor(i => i.CasketManufacturerType)
            .HasAgreement(response, "CasketManufacturerType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Casket Manufacturer must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Burial Container Type
            RuleFor(i => i.BurialContainerType)
            .HasAgreement(response, "BurialContainerType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Burial Container must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Transportation Of Family Type
            RuleFor(i => i.TransportationOfFamilyType)
            .HasAgreement(response, "TransportationOfFamilyType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Transportation of family must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Flower Spray Type
            RuleFor(i => i.FlowerSprayType)
            .HasAgreement(response, "FlowerSprayType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Flower Spray must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Primary Flower Type
            RuleFor(i => i.PrimaryFlowerType)
            .HasAgreement(response, "PrimaryFlowerType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Primary Flower must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Secondary Flower Type
            RuleFor(i => i.SecondaryFlowerType)
            .HasAgreement(response, "SecondaryFlowerType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Secondary Flower must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion

            #region Accent Flower Type
            RuleFor(i => i.AccentFlowerType)
            .HasAgreement(response, "AccentFlowerType")
            .When(i => (validationMode == ValidationMode.Pending))
            .WithMessage("Accent Flower must be specified")
            .WithValidationContext(ValidationStatus.Required);
            #endregion
        }