Exemple #1
0
 public virtual Guid AddSolution(Solution solution)
 {
     return Guid.NewGuid();
 }
        SolutionDto IAdaptor.AdaptSolution(Solution domainSolution)
        {
            var dtoProducts = new List<ProductDto>();

              foreach (var product in domainSolution.Products)
              {
            dtoProducts.Add(((IMortgageAdaptor)this).AdaptProduct(product));
              }

              RequirementDto dtoRequirement = null;
              if (domainSolution.Requirement is BuyToLetRequirement) {
            dtoRequirement = ((IMortgageAdaptor)this).AdaptRequirement((BuyToLetRequirement) domainSolution.Requirement);
              }
              else if (domainSolution.Requirement is RateSwitchRequirement){
            dtoRequirement = ((IMortgageAdaptor)this).AdaptRequirement((RateSwitchRequirement)domainSolution.Requirement);
              }
              else if (domainSolution.Requirement is HousePurchaseRequirement){
            dtoRequirement = ((IMortgageAdaptor)this).AdaptRequirement((HousePurchaseRequirement)domainSolution.Requirement);
              }
              else{
            throw new InvalidDataException("We shouldn't be here");
               }

              var dtoSolution = new MortgageSolutionDto(dtoProducts, (MortgageRequirementDto) dtoRequirement);

              return dtoSolution;
        }