/// <summary> /// Insert the motor endorsement type of cancel. /// </summary> /// <param name="motorEndorsement">Motor endorsement request</param> /// <returns>Motorendorsementid, Motorendorsementnumber.</returns> public MotorEndorsementResult PostAdminMotorEndorsement(BO.MotorEndorsement motorEndorsement) { MotorEndorsementResult result = InsertAdminMotorEndorsement(motorEndorsement); if (result.IsTransactionDone) { var req = new BO.MotorProductRequest { Type = "fetch", Agency = motorEndorsement.Agency, AgentCode = motorEndorsement.AgencyCode, MainClass = motorEndorsement.Mainclass, SubClass = motorEndorsement.Subclass, }; BO.MotorProductMasterResponse productRes = _adminRepository.GetMotorProduct(req); BO.MotorProductMaster product = productRes.motorProductMaster[0]; if (productRes != null && productRes.IsTransactionDone && productRes.motorProductMaster.Count > 0) { var endorsementType = product.MotorEndorsementMaster .Find(c => c.EndorsementType == motorEndorsement.EndorsementType); if (endorsementType != null && endorsementType.HasCommission && motorEndorsement.PremiumBeforeDiscount > endorsementType.ChargeAmount) { CalculateCommission(product, motorEndorsement, motorEndorsement.MotorID, result.DocumentNo, result.LinkID, motorEndorsement.RenewalCount, result.EndorsementCount, result.EndorsementNo, result.MotorEndorsementID); } } } return(result); }
/// <summary> /// Insert the motor endorsement. /// </summary> /// <param name="motorEndorsement">Motor endorsement details.</param> /// <returns>Motorendorsementid, Motorendorsementnumber.</returns> public MotorEndorsementResult PostMotorEndorsement(BO.MotorEndorsement motorEndorsement) { try { var req = new BO.MotorProductRequest { Type = "fetch", Agency = motorEndorsement.Agency, AgentCode = motorEndorsement.AgencyCode, MainClass = motorEndorsement.Mainclass, SubClass = motorEndorsement.Subclass, }; BO.MotorProductMasterResponse productRes = _adminRepository.GetMotorProduct(req); BO.MotorProductMaster product = productRes.motorProductMaster[0]; MotorEndorsementResult result = InsertMotorEndorsement(motorEndorsement); if (result.IsTransactionDone) { if (productRes != null && productRes.IsTransactionDone && productRes.motorProductMaster.Count > 0) { var endorsementType = product.MotorEndorsementMaster .Find(c => c.EndorsementType == motorEndorsement.EndorsementType); if (endorsementType != null && endorsementType.HasCommission && motorEndorsement.PremiumBeforeDiscount > endorsementType.ChargeAmount) { CalculateCommission(product, motorEndorsement, motorEndorsement.MotorID, result.DocumentNo, result.LinkID, motorEndorsement.RenewalCount, result.EndorsementCount, result.EndorsementNo, result.MotorEndorsementID); } } } return(result); } catch (Exception ex) { _mail.SendMailLogError(ex.Message, motorEndorsement.InsuredCode, "MotorEndorsement", motorEndorsement.Agency, false); return(new MotorEndorsementResult() { IsTransactionDone = false, TransactionErrorMessage = ex.Message }); } }
public BKIC.SellingPoint.DL.BO.MotorInsurancePolicyResponse InsertMotor(BO.MotorInsurancePolicy policy) { try { var req = new BO.MotorProductRequest { Type = "fetch", Agency = policy.Agency, AgentCode = policy.AgencyCode, MainClass = policy.Mainclass, SubClass = policy.Subclass, }; BO.MotorProductMasterResponse productRes = _adminRepository.GetMotorProduct(req); if (productRes != null && productRes.IsTransactionDone && productRes.motorProductMaster.Count > 0) { BO.MotorProductMaster product = productRes.motorProductMaster[0]; if (product != null) { Calculate(policy, product); var policyRecord = InsertMotorMain(policy, policy.IsRenewal ? MotorInsuranceSP.MotorRenewalInsert : MotorInsuranceSP.MotorInsert); if (policyRecord != null && policyRecord.IsInserted) { CalculateCommission(product, policy, policyRecord.NewMotorID, policyRecord.DocumentNumber, policyRecord.LinkID, policyRecord.RenewalCount); if (!IsHIR && policy.IsActivePolicy) { try { new Task(() => { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@MotorID", policyRecord.NewMotorID) }; SellingPointSQL.eds("MIG_IntegrateMotorDetails", para); }).Start(); } catch (AggregateException ex) { foreach (Exception inner in ex.InnerExceptions) { _mail.SendMailLogError(inner.Message, policy.InsuredCode, "MotorInsurance", policy.Agency, true); } } } return(new BKIC.SellingPoint.DL.BO.MotorInsurancePolicyResponse() { IsTransactionDone = true, IsHIR = IsHIR, MotorID = policyRecord.NewMotorID, DocumentNo = policyRecord.DocumentNumber, RenewalCount = policyRecord.RenewalCount }); } } return(new BKIC.SellingPoint.DL.BO.MotorInsurancePolicyResponse() { IsTransactionDone = false, TransactionErrorMessage = "Product not found" }); } return(new BKIC.SellingPoint.DL.BO.MotorInsurancePolicyResponse() { IsTransactionDone = false, TransactionErrorMessage = "Product not found" }); } catch (Exception ex) { _mail.SendMailLogError(ex.Message, policy.InsuredCode, "MotorInsurance", policy.Agency, false); return(new MotorInsurancePolicyResponse() { IsTransactionDone = false, TransactionErrorMessage = ex.ToString() }); } }