Ejemplo n.º 1
0
 public IInsureeLogic GetInsureeLogic()
 {
     if (_insureeLogic == null)
     {
         _insureeLogic = new InsureeLogic(this.imisModules);
     }
     return(_insureeLogic);
 }
Ejemplo n.º 2
0
 public IInsureeLogic GetInsureeLogic()
 {
     if (_insureeLogic == null)
     {
         _insureeLogic = new InsureeLogic(_configuration);
     }
     return(_insureeLogic);
 }
Ejemplo n.º 3
0
        public async Task <FamilyModel> AddFamilyAsync(FamilyModel family)
        {
            // Authorize user

            // Validate input
            #region Validate input

            /// TODO: think of a strategy for validation => one solution to have one validation class that creates only
            /// one SQL call to check different validations => only one SQL access for validation

            // check at least one insuree in the family
            NotEmptyFamilyValidator      notEmptyFamilyValidator      = new NotEmptyFamilyValidator(null);
            OnlyOneHeadInFamilyValidator onlyOneHeadInFamilyValidator = new OnlyOneHeadInFamilyValidator(notEmptyFamilyValidator);
            onlyOneHeadInFamilyValidator.Validate(family);

            // check each insuree number is correct and unique
            /// TODO: add only one validator for the Insuree class as it will be used here and in the InsureeLogic
            IInsureeLogic insureeLogic = this.imisModules.GetInsureeManagementModule().GetInsureeLogic();
            UniqueInsureeNumberValidator uniqueInsureeNumberValidator = new UniqueInsureeNumberValidator(insureeLogic, insureeNumberValidator);
            foreach (InsureeModel insuree in family.Insurees)
            {
                await uniqueInsureeNumberValidator.ValidateAsync(insuree.CHFID);
            }

            #endregion

            // Execute business behaviour
            FamilyModel newFamily = await familyRepository.AddNewFamilyAsync(family);

            // Validate results

            // Validate data access rights

            // Return results
            return(newFamily);
        }
 public UniqueInsureeNumberValidator(IInsureeLogic insureeLogic, IValidator validator)
 {
     this.validator    = validator;
     this.insureeLogic = insureeLogic;
 }
Ejemplo n.º 5
0
 public IInsureeManagementModule SetInsureeLogic(IInsureeLogic insureeLogic)
 {
     _insureeLogic = insureeLogic;
     return(this);
 }