예제 #1
0
 public IHttpActionResult GetPolicyInfoRecordingByID([FromBody] JObject data)
 {
     try
     {
         int policyInfoRecID = !string.IsNullOrEmpty(data.SelectToken("PolicyInfoRecID").Value <string>()) ? Convert.ToInt32(data.SelectToken("PolicyInfoRecID").Value <string>()) : 0;
         var policyInfoRec   = managePolicyInfoRecording.GetPolicyInfoRecordingByID(policyInfoRecID);
         return(Json(new
         {
             status = true,
             data = policyInfoRec
         }));
     }
     catch (Exception ex)
     {
         return(Json(new { status = false, message = "Unknown error occurred" }));
     }
 }
예제 #2
0
        public PaymentVM GetPaymentByID(int paymentID)
        {
            try
            {
                ManagePolicyInfoRecording managePolicyInfoRecording = new ManagePolicyInfoRecording();

                var paymentData = unitOfWork.TblPaymentRepository.GetByID(paymentID);

                PaymentVM paymentVM = new PaymentVM();
                paymentVM.PaymentID = paymentData.PaymentID;
                paymentVM.ClientID  = paymentData.ClientID != null?Convert.ToInt32(paymentData.ClientID) : 0;

                if (paymentVM.ClientID > 0)
                {
                    paymentVM.ClientName = paymentData.tblClient.ClientName;
                }

                paymentVM.PaymentAmount = paymentData.PaymentAmount != null?Convert.ToDecimal(paymentData.PaymentAmount) : 0;

                paymentVM.CreatedBy = paymentData.CreatedBy != null?Convert.ToInt32(paymentData.CreatedBy) : 0;

                paymentVM.CreatedDate = paymentData.CreatedDate != null?paymentData.CreatedDate.ToString() : string.Empty;

                paymentVM.ModifiedBy = paymentData.ModifiedBy != null?Convert.ToInt32(paymentData.ModifiedBy) : 0;

                paymentVM.ModifiedDate = paymentData.ModifiedDate != null?paymentData.ModifiedDate.ToString() : string.Empty;

                List <tblPolicyDebitNote> policyDebitNoteList = unitOfWork.TblPolicyDebitNoteRepository.Get(x => x.PaymentID == paymentData.PaymentID).ToList();
                List <tblPolicyDebitNote> debitNoteList       = policyDebitNoteList.GroupBy(x => x.DebitNoteID).Select(x => x.FirstOrDefault()).ToList();

                List <DebitNoteVM> debitNoteVMList = new List <DebitNoteVM>();

                foreach (var debitNote in debitNoteList)
                {
                    DebitNoteVM debitNoteVM = new DebitNoteVM();
                    debitNoteVM.DebitNoteID = debitNote.tblDebitNote.DebitNoteID;
                    debitNoteVM.TotalNonCommissionPremium = debitNote.tblDebitNote.TotalNonCommissionPremium != null?Convert.ToDecimal(debitNote.tblDebitNote.TotalNonCommissionPremium) : 0;

                    debitNoteVM.TotalGrossPremium = debitNote.tblDebitNote.TotalGrossPremium != null?Convert.ToDecimal(debitNote.tblDebitNote.TotalGrossPremium) : 0;

                    debitNoteVM.CreatedBy = debitNote.tblDebitNote.CreatedBy != null?Convert.ToInt32(debitNote.tblDebitNote.CreatedBy) : 0;

                    debitNoteVM.CreatedDate = debitNote.tblDebitNote.CreatedDate != null?debitNote.tblDebitNote.CreatedDate.ToString() : string.Empty;

                    debitNoteVM.ModifiedBy = debitNote.tblDebitNote.ModifiedBy != null?Convert.ToInt32(debitNote.tblDebitNote.ModifiedBy) : 0;

                    debitNoteVM.ModifiedDate = debitNote.tblDebitNote.ModifiedDate != null?debitNote.tblDebitNote.ModifiedDate.ToString() : string.Empty;

                    List <tblPolicyDebitNote> policyInfoPaymentList = policyDebitNoteList.Where(x => x.DebitNoteID == debitNote.DebitNoteID).ToList();

                    List <PolicyInfoPaymentVM> policyInfoPaymentVMList = new List <PolicyInfoPaymentVM>();

                    foreach (var policyInfoPayment in policyInfoPaymentList)
                    {
                        PolicyInfoPaymentVM policyInfoPaymentVM = new PolicyInfoPaymentVM();
                        policyInfoPaymentVM.PolicyInfoPaymentID = policyInfoPayment.tblPolicyInfoPayment.PolicyInfoPaymentID;
                        policyInfoPaymentVM.PolicyInfoRecID     = policyInfoPayment.tblPolicyInfoPayment.PolicyInfoRecID != null?Convert.ToInt32(policyInfoPayment.tblPolicyInfoPayment.PolicyInfoRecID) : 0;

                        if (policyInfoPaymentVM.PolicyInfoRecID > 0)
                        {
                            policyInfoPaymentVM.PolicyInfoRecObj = managePolicyInfoRecording.GetPolicyInfoRecordingByID(policyInfoPaymentVM.PolicyInfoRecID);
                            debitNoteVM.PolicyInfoPaymentLists   = policyInfoPaymentVM.PolicyInfoRecObj.BankTransactionList;
                        }

                        policyInfoPaymentVM.NonCommissionPremium = policyInfoPayment.tblPolicyInfoPayment.NonCommissionPremium != null?Convert.ToDecimal(policyInfoPayment.tblPolicyInfoPayment.NonCommissionPremium) : 0;

                        policyInfoPaymentVM.GrossPremium = policyInfoPayment.tblPolicyInfoPayment.GrossPremium != null?Convert.ToDecimal(policyInfoPayment.tblPolicyInfoPayment.GrossPremium) : 0;

                        policyInfoPaymentVM.CreatedBy = policyInfoPayment.tblPolicyInfoPayment.CreatedBy != null?Convert.ToInt32(policyInfoPayment.tblPolicyInfoPayment.CreatedBy) : 0;

                        policyInfoPaymentVM.CreatedDate = policyInfoPayment.tblPolicyInfoPayment.CreatedDate != null?policyInfoPayment.tblPolicyInfoPayment.CreatedDate.ToString() : string.Empty;

                        policyInfoPaymentVM.ModifiedBy = policyInfoPayment.tblPolicyInfoPayment.ModifiedBy != null?Convert.ToInt32(policyInfoPayment.tblPolicyInfoPayment.ModifiedBy) : 0;

                        policyInfoPaymentVM.ModifiedDate = policyInfoPayment.tblPolicyInfoPayment.ModifiedDate != null?policyInfoPayment.tblPolicyInfoPayment.ModifiedDate.ToString() : string.Empty;

                        List <tblPolicyInfoCharge> policyInfoChargeList = unitOfWork.TblPolicyInfoChargeRepository.Get(x => x.PolicyInfoPaymentID == policyInfoPayment.PolicyInfoPaymentID).ToList();

                        List <PolicyInfoChargeVM> policyInfoChargeVMList = new List <PolicyInfoChargeVM>();

                        foreach (var policyInfoCharge in policyInfoChargeList)
                        {
                            PolicyInfoChargeVM policyInfoChargeVM = new PolicyInfoChargeVM();
                            policyInfoChargeVM.PolicyInfoChargeID = policyInfoPaymentVM.PolicyInfoRecID;
                            policyInfoChargeVM.ChargeTypeID       = policyInfoCharge.ChargeTypeID != null?Convert.ToInt32(policyInfoCharge.ChargeTypeID) : 0;

                            if (policyInfoChargeVM.ChargeTypeID > 0)
                            {
                                tblChargeType chargeTypeDetails = unitOfWork.TblChargeTypeRepository.GetByID(policyInfoChargeVM.ChargeTypeID);

                                policyInfoChargeVM.ChargeTypeName = chargeTypeDetails.ChargeType;
                            }

                            policyInfoChargeVM.Amount = policyInfoCharge.Amount != null?Convert.ToDecimal(policyInfoCharge.Amount) : 0;

                            policyInfoChargeVM.IsCR      = (bool)policyInfoCharge.IsCR;
                            policyInfoChargeVM.CreatedBy = policyInfoCharge.CreatedBy != null?Convert.ToInt32(policyInfoCharge.CreatedBy) : 0;

                            policyInfoChargeVM.CreatedDate = policyInfoCharge.CreatedDate != null?policyInfoCharge.CreatedDate.ToString() : string.Empty;

                            policyInfoChargeVM.ModifiedBy = policyInfoCharge.ModifiedBy != null?Convert.ToInt32(policyInfoCharge.ModifiedBy) : 0;

                            policyInfoChargeVM.ModifiedDate = policyInfoCharge.ModifiedDate != null?policyInfoCharge.ModifiedDate.ToString() : string.Empty;

                            policyInfoChargeVMList.Add(policyInfoChargeVM);
                        }

                        policyInfoPaymentVM.PolicyInfoChargeList = policyInfoChargeVMList;

                        policyInfoPaymentVMList.Add(policyInfoPaymentVM);
                    }

                    //  debitNoteVM.PolicyInfoPaymentList = policyInfoPaymentVMList;


                    debitNoteVMList.Add(debitNoteVM);
                }

                paymentVM.DebitNoteList = debitNoteVMList;

                return(paymentVM);
            }
            catch (Exception ex)
            {
                throw;
            }
        }