コード例 #1
0
ファイル: PolicyService.cs プロジェクト: bhaskar2583/idoc
        public PolicyModel GetById(int Id)
        {
            var entity = _policyRepository.GetById(Id);

            if (entity != null)
            {
                var policy = new PolicyModel()
                {
                    Id               = entity.Id,
                    IsActive         = (bool)entity.IsActive,
                    PolicyNumber     = entity.PolicyNumber,
                    CarId            = entity.CarId,
                    CoverageId       = entity.CoverageId,
                    ProductId        = entity.ProductId,
                    EffectiveDate    = entity.EffectiveDate,
                    EndDate          = entity.EndDate,
                    IsGroupInsurance = (bool)entity.IsGroupInsurance,
                    AddUser          = entity.AddUser,
                    AddDate          = entity.AddDate,
                    RevUser          = entity.RevUser,
                    RevDate          = entity.RevDate
                };

                var carrier  = _carrierService.GetById(policy.CarId);
                var coverage = _commonService.GetCoverageById(policy.CoverageId);
                var product  = _commonService.GetProductById(policy.ProductId);
                MapSelectedCarrier(policy, carrier);
                MapSelectedProduct(policy, product);
                MapSelectedCoverage(policy, coverage);
                return(policy);
            }

            return(null);
        }
コード例 #2
0
        public CalculationDTO AddCalculation(CalculationDTO calculation)
        {
            var calc = calculationService.AddCalculation(new PolicyId(calculation.PolicyId),
                                                         new PeriodId(calculation.PeriodId), calculation.Name, calculation.EmployeeIdList);
            var res = new CalculationWithPolicyAndPeriod
            {
                Calculation = calc,
                Policy      = PolicyRep.GetById(calc.PolicyId),
                Period      = PeriodRep.GetById(calc.PeriodId)
            };

            return(calculationMapper.MapToModel(res));
        }
コード例 #3
0
 public IActionResult GetDetails(int policyNumber)
 {
     try
     {
         var dbPolicy = _policyRepository.GetById(policyNumber);
         if (dbPolicy.IsObjectNull())
         {
             return(BadRequest("Policy number not exists"));
         }
         else
         {
             return(Ok(dbPolicy));
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(500, "Internal server error"));
     }
 }
コード例 #4
0
ファイル: PolicyService.cs プロジェクト: mehabadi/HPMS
 public Policy UpdatePolicy(PolicyId policyId, string name, string dictionaryName)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             var policy = policyRep.GetById(policyId);
             policy.Update(name, dictionaryName);
             scope.Complete();
             return(policy);
         }
     }
     catch (Exception exp)
     {
         var res = policyRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
コード例 #5
0
        public Task <ConfirmTerminationResult> Handle(ConfirmTerminationCommand request, CancellationToken cancellationToken)
        {
            var policy = policyRepository.GetById(request.PolicyId);

            policy.ConfirmTermination();

            policyRepository.Save(policy, policy.Version);

            return(Task.FromResult(new ConfirmTerminationResult
            {
                PolicyId = policy.Id,
                VersionConfirmed = policy.Versions.LastActive().VersionNumber
            }));
        }
コード例 #6
0
        public Task <TerminatePolicyResult> Handle(TerminatePolicyCommand request, CancellationToken cancellationToken)
        {
            var policy = policyRepository.GetById(request.PolicyId);

            policy.TerminatePolicy(request.TerminationDate);

            policyRepository.Save(policy, policy.Version);

            return(Task.FromResult(new TerminatePolicyResult
            {
                PolicyId = policy.Id,
                VersionWithTerminationNumber = policy.Versions.Last().VersionNumber
            }));
        }
コード例 #7
0
        public Task <BuyAdditionalCoverResult> Handle(BuyAdditionalCoverCommand request, CancellationToken cancellationToken)
        {
            var policy = policyRepository.GetById(request.PolicyId);

            policy.ExtendCoverage
            (
                request.EffectiveDateOfChange,
                new CoverPrice(request.NewCoverCode, request.NewCoverPrice, request.NewCoverPriceUnit)
            );

            return(Task.FromResult
                   (
                       new BuyAdditionalCoverResult
            {
                PolicyNumber = policy.PolicyNumber,
                VersionWithAdditionalCoversNumber = policy.Versions.Last().VersionNumber
            }
                   ));
        }
コード例 #8
0
ファイル: CalculatorEngine.cs プロジェクト: mehabadi/HPMS
        public void fetchPolicyAndEmployees(Calculation calculation, bool doResume, int pathNo, out Policy policy, out Dictionary <int, IList <Employee> > employees, out Period period)
        {
            using (var transaction = new TransactionScope())
            {
                policy = policyRep.GetById(calculation.PolicyId);
                if (policy is RuleEngineBasedPolicy)
                {
                    var dummy  = (policy as RuleEngineBasedPolicy).RuleFunctions;
                    var dummy2 = (policy as RuleEngineBasedPolicy).Rules;
                }
                period = periodRep.GetById(calculation.PeriodId);

                var en = calculation.EmployeeIdList.Select(i => i.EmployeeNo).ToList();
                if (!doResume)
                {
                    employees = empRep.FindInListWithPath(en, calculation.PeriodId, pathNo);
                }
                else
                {
                    employees = empRep.FindRemainingEmployeesOfCalculation(en, calculation.PeriodId, calculation.Id, pathNo);
                }
                transaction.Complete();
            }
        }
コード例 #9
0
ファイル: CalculationService.cs プロジェクト: mehabadi/HPMS
 public Calculation AddCalculation(PolicyId policyId, PeriodId periodId, string name, string employeeIdDelimitedList)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var calculation = new Calculation(calculationRep.GetNextId(), periodRep.GetById(periodId),
                                               PolicyRep.GetById(policyId), name, DateTime.Now,
                                               employeeIdDelimitedList);
             calculationRep.Add(calculation);
             tr.Complete();
             return(calculation);
         }
     }
     catch (Exception exp)
     {
         var res = calculationRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
コード例 #10
0
ファイル: PolicyFacadeService.cs プロジェクト: mehabadi/HPMS
        public PolicyDTO GetPolicyById(long id)
        {
            var policy = policyRep.GetById(new PolicyId(id));

            return(policyMapper.MapToModel(policy));
        }
コード例 #11
0
        public ActionResult GetById(int id)
        {
            var model = _policyRepository.GetById(id);

            return(Ok(model));
        }
コード例 #12
0
ファイル: CommonService.cs プロジェクト: bhaskar2583/idoc
        public bool AddClientPolocyBudget(AddPolicyBudget budget)
        {
            var cpDetails      = _commonRepository.GetAllClientPolicies().Where(c => c.ClientId == budget.ClientId).OrderByDescending(cp => cp.Id);
            var pDetails       = _policyRepository.GetById(budget.PolicyId);
            var carrierProduct = _commonRepository.GetAllCorporateXProducts().FirstOrDefault(cp => cp.ProductId == pDetails.ProductId);

            cpDetails.ToList().ForEach(cp =>
            {
                var pDetailsChild       = _policyRepository.GetById(cp.PolicieId);
                var carrierProductChild = _commonRepository.GetAllCorporateXProducts()
                                          .FirstOrDefault(cpp => cpp.ProductId == pDetailsChild.ProductId);

                if (carrierProductChild != null && carrierProduct.CorporateProductId == carrierProductChild.CorporateProductId &&
                    pDetailsChild.PolicyNumber == pDetails.PolicyNumber &&
                    pDetailsChild.CarId == pDetails.CarId)
                {
                    budget.PolicyId = pDetailsChild.Id;
                }
            });
            foreach (var month in DateUtil.GetMonths())
            {
                var entity = new ClientPolicyBudget()
                {
                    ClientId       = budget.ClientId,
                    PolicyId       = budget.PolicyId,
                    ClientPolicyId = budget.ClientPolicyId,
                    IsActive       = true,
                    AddUser        = LoginUserDetails.GetWindowsLoginUserName(),
                    AddDate        = DateUtil.GetCurrentDate(),
                    BudgetYear     = budget.Year,
                    BudgetMonth    = month
                };

                switch (entity.BudgetMonth.ToLower())
                {
                case "jan":
                    entity.BudgetValue = budget.JanBudget;
                    break;

                case "feb":
                    entity.BudgetValue = budget.FebBudget;
                    break;

                case "mar":
                    entity.BudgetValue = budget.MarchBudget;
                    break;

                case "apr":
                    entity.BudgetValue = budget.AprilBudget;
                    break;

                case "may":
                    entity.BudgetValue = budget.MayBudget;
                    break;

                case "jun":
                    entity.BudgetValue = budget.JunBudget;
                    break;

                case "jul":
                    entity.BudgetValue = budget.JulyBudget;
                    break;

                case "aug":
                    entity.BudgetValue = budget.AugBudget;
                    break;

                case "sep":
                    entity.BudgetValue = budget.SepBudget;
                    break;

                case "oct":
                    entity.BudgetValue = budget.OctBudget;
                    break;

                case "nov":
                    entity.BudgetValue = budget.NovBudget;
                    break;

                case "dec":
                    entity.BudgetValue = budget.DecBudget;
                    break;
                }

                _commonRepository.AddClientPolocyBudget(entity);
            }
            return(true);
        }
コード例 #13
0
 /// <summary>
 /// The GetById.
 /// </summary>
 /// <param name="policyId">The policyId<see cref="long"/>.</param>
 /// <returns>The <see cref="Policy"/>.</returns>
 public Policy GetById(long policyId)
 {
     return(_policyRepository.GetById(policyId));
 }
コード例 #14
0
        public List <CommisionModel> GetAllSavedCommissionsForCarrier(int carrierId)
        {
            var commissionModel = new List <CommisionModel>();
            var commissions     = _commissionRepository.GetSavedCommisionsForCarrier(carrierId);

            commissions.ForEach(dc =>
            {
                var cpDetails     = _commonRepository.GetAllClientPoliciesByIndexId(dc.ClientPolicyId).FirstOrDefault();
                var policyDetails = _policyRepository.GetById(cpDetails.PolicieId);
                var product       = _commonRepository.GetProductById(policyDetails.ProductId);
                var coverage      = _commonRepository.GetCoverageById(policyDetails.CoverageId);
                var clientDetails = _clientRepository.GetById(cpDetails.ClientId);
                var carrier       = _carrierRepository.GetById(policyDetails.CarId);

                commissionModel.Add(new CommisionModel()
                {
                    Id = dc.Id,
                    ReconcilationPaymentDate         = dc.ReconcilationDate,
                    ReconcilationPaymentDateAsString = GetDateFormat(dc.ReconcilationDate),
                    ReconsilationStatus   = string.IsNullOrEmpty(dc.ReconcilationStatus) ? "Open" : "Verified",
                    ReconsilationStatusId = string.IsNullOrEmpty(dc.ReconcilationStatus) ? 1 : 2,
                    ClientId     = clientDetails.Id,
                    CoverageId   = coverage.Id,
                    CoverageName = coverage.Name,

                    PolicyId     = policyDetails.Id,
                    PolicyNumber = policyDetails.PolicyNumber,

                    ProductId   = product.Id,
                    ProductName = product.Name,

                    CleintName = clientDetails.Name,


                    ClientPolicyId          = dc.ClientPolicyId,
                    CarrierId               = policyDetails.CarId,
                    CarrierName             = carrier.Name,
                    CommisionValue          = dc.CommisionValue,
                    CommisionString         = dc.CommisionString,
                    StatementDateAsString   = GetDateFormat(dc.StatementDate),
                    StatementDate           = dc.StatementDate,
                    AppliedDate             = dc.AppliedDate,
                    AppliedDateAsString     = GetDateFormatMMYYYY(dc.AppliedDate),
                    AppliedDateAsFullString = GetDateFormat(dc.AppliedDate),
                    PaymentId               = dc.PaymentId,
                    DivisionName            = clientDetails.Division,
                    Git = policyDetails.IsGroupInsurance
                });
            });

            commissionModel.ForEach(cm =>
            {
                if (!string.IsNullOrEmpty(cm.DivisionName))
                {
                    if (cm.DivisionName == "HBS")
                    {
                        cm.DivisionId = 1;
                    }
                    if (cm.DivisionName == "SBS")
                    {
                        cm.DivisionId = 2;
                    }
                }

                var carrierProduct = _commonRepository.GetAllCorporateXProducts().FirstOrDefault(cp => cp.ProductId == cm.ProductId);
                if (carrierProduct != null)
                {
                    var cp = _commonRepository.GetAllCorporateProducts().FirstOrDefault(cpp => cpp.Id == carrierProduct.CorporateProductId);
                    if (cp != null)
                    {
                        cm.SelectedCorporateProduct = new CorporateProduct()
                        {
                            Id   = cp.Id,
                            Name = cp.Name
                        };
                    }
                }
            });
            return(commissionModel);
        }