public ActionResult AddAccount(int?AcHeadID, decimal?Amount, string Remarks, string TransType = "CN") { int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); DateTime fromdate = Convert.ToDateTime(Session["FyearFrom"].ToString()); DateTime todate = Convert.ToDateTime(Session["FyearTo"].ToString()); List <DebitNoteDetailVM> list = (List <DebitNoteDetailVM>)Session["DebitNoteDetail"]; DebitNoteDetailVM item = new DebitNoteDetailVM(); if (list != null) { item = list.Where(cc => cc.AcHeadID == AcHeadID).FirstOrDefault(); } else { list = new List <DebitNoteDetailVM>(); } if (item == null) { item = new DebitNoteDetailVM(); item.AcHeadID = Convert.ToInt32(AcHeadID); item.AcHeadName = db.AcHeads.Find(item.AcHeadID).AcHead1; item.Amount = Amount; item.Remarks = Remarks; list.Add(item); } Session["DebitNoteDetail"] = list; DebitNoteVM vm = new DebitNoteVM(); vm.Details = list; return(PartialView("DebitNoteDetail", vm)); }
public ActionResult ServiceList() { var data = db.DebitNotes.ToList(); List <DebitNoteVM> lst = new List <DebitNoteVM>(); foreach (var item in data) { string jobcode = ""; //var job = (from c in db.JInvoices where c.InvoiceID == item.InvoiceID select c).FirstOrDefault(); //if(job!=null) //{ // var jobid = job.JobID; // jobcode = (from j in db.JobGenerations where j.JobID == jobid select j.JobCode).FirstOrDefault(); //} //else //{ var purchaseinvoice = (from d in db.PurchaseInvoices where d.PurchaseInvoiceID == item.InvoiceID && d.IsShipping == false select d).FirstOrDefault(); jobcode = purchaseinvoice.PurchaseInvoiceNo; //} string supplier = (from c in db.Suppliers where c.SupplierID == item.SupplierID select c.SupplierName).FirstOrDefault(); DebitNoteVM v = new DebitNoteVM(); v.JobNo = jobcode; v.Date = item.DebitNoteDate.Value; v.SupplierName = supplier; v.Amount = item.Amount.Value; lst.Add(v); } return(View(lst)); }
public ActionResult DeleteAccount(int index) { int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); DateTime fromdate = Convert.ToDateTime(Session["FyearFrom"].ToString()); DateTime todate = Convert.ToDateTime(Session["FyearTo"].ToString()); List <DebitNoteDetailVM> list = (List <DebitNoteDetailVM>)Session["DebitNoteDetail"]; List <DebitNoteDetailVM> list1 = new List <DebitNoteDetailVM>(); DebitNoteDetailVM item = new DebitNoteDetailVM(); list.RemoveAt(index); Session["DebitNoteDetail"] = list; DebitNoteVM vm = new DebitNoteVM(); vm.Details = list; return(PartialView("DebitNoteDetail", vm)); }
public ActionResult Index() { var data = db.DebitNotes.OrderByDescending(c => c.DebitNoteDate).ToList(); List <DebitNoteVM> lst = new List <DebitNoteVM>(); foreach (var item in data) { //string jobcode = ""; //if (item.InvoiceType == "TR") //{ // var purchaseinvoice = (from d in db.SupplierInvoices where d.SupplierInvoiceID == item.InvoiceID select d).FirstOrDefault(); // jobcode = purchaseinvoice.InvoiceNo; //} //else if (item.InvoiceType == "OP") //{ // var purchaseinvoice = (from d in db.AcOPInvoiceDetails where d.AcOPInvoiceDetailID == item.InvoiceID select d).FirstOrDefault(); // jobcode = purchaseinvoice.InvoiceNo; //} string supplier = (from c in db.SupplierMasters where c.SupplierID == item.SupplierID select c.SupplierName).FirstOrDefault(); DebitNoteVM v = new DebitNoteVM(); v.DebitNoteNo = item.DebitNoteNo; v.DebitNoteId = item.DebitNoteID; //v.JobNo = jobcode; v.Remarks = item.Remarks; v.Date = item.DebitNoteDate.Value; v.SupplierName = supplier; v.Amount = item.Amount.Value; lst.Add(v); } return(View(lst)); }
public ActionResult Create1(DebitNoteVM v) { AcJournalMaster ajm = new AcJournalMaster(); int acjm = 0; acjm = (from c in db.AcJournalMasters orderby c.AcJournalID descending select c.AcJournalID).FirstOrDefault(); ajm.AcJournalID = acjm + 1; ajm.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); ajm.AcFinancialYearID = Convert.ToInt32(Session["fyearid"].ToString()); ajm.PaymentType = 1; ajm.Remarks = "Debit Note"; ajm.StatusDelete = false; ajm.TransDate = v.Date; ajm.VoucherNo = "DB-" + ajm.AcJournalID; ajm.TransType = 1; ajm.VoucherType = ""; db.AcJournalMasters.Add(ajm); db.SaveChanges(); AcJournalDetail a = new AcJournalDetail(); int maxacj = 0; maxacj = (from c in db.AcJournalDetails orderby c.AcJournalDetailID descending select c.AcJournalDetailID).FirstOrDefault(); a.AcJournalDetailID = maxacj + 1; a.AcJournalID = ajm.AcJournalID; a.AcHeadID = v.AcHeadID; a.Amount = v.Amount; a.BranchID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); a.Remarks = ""; db.AcJournalDetails.Add(a); db.SaveChanges(); AcJournalDetail b = new AcJournalDetail(); maxacj = (from c in db.AcJournalDetails orderby c.AcJournalDetailID descending select c.AcJournalDetailID).FirstOrDefault(); b.AcJournalDetailID = maxacj + 1; b.AcJournalID = ajm.AcJournalID; b.AcHeadID = v.AcHeadID; b.Amount = -v.Amount; b.BranchID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); b.Remarks = ""; db.AcJournalDetails.Add(b); db.SaveChanges(); //var ids = (from x in db.PurchaseInvoiceDetails where x.PurchaseInvoiceID == v.InvoiceNo select (int?)x.PurchaseInvoiceDetailID).ToList(); //int recpayid = (from c in db.RecPayDetails where ids.Contains(c.InvoiceID) select c.RecPayID).FirstOrDefault().Value; int recpayid = 0; int max = 0; var data = (from c in db.DebitNotes orderby c.DebitNoteID descending select c).FirstOrDefault(); if (data == null) { max = 1; } else { max = data.DebitNoteID + 1; } DebitNote d = new DebitNote(); d.DebitNoteID = max + 1; d.DebitNoteNo = "D-" + (max + 1); d.InvoiceID = v.InvoiceID; d.DebitNoteDate = v.Date; d.Amount = v.Amount; d.AcJournalID = ajm.AcJournalID; d.FYearID = Convert.ToInt32(Session["fyearid"].ToString()); d.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); d.RecPayID = recpayid; d.AcHeadID = v.AcHeadID; d.SupplierID = v.SupplierID; d.InvoiceType = "S"; //d.IsShipping = true; d.Remarks = v.Remarks; db.DebitNotes.Add(d); db.SaveChanges(); TempData["SuccessMsg"] = "Successfully Added Debit Note"; return(RedirectToAction("List", "DebitNote")); }
public ActionResult Create(int id = 0) { //List<Invoices> lst = new List<Invoices>(); //ViewBag.Supplier = db.SupplierMasters.OrderBy(x => x.SupplierName).ToList(); //ViewBag.AcHead = db.AcHeads.OrderBy(x => x.AcHead1).ToList(); //ViewBag.Invoice = lst; //return View(); int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); ViewBag.Supplier = db.SupplierMasters.OrderBy(x => x.SupplierName).ToList(); ViewBag.AcHead = db.AcHeads.OrderBy(x => x.AcHead1).ToList(); if (id == 0) { ViewBag.Title = "DEBIT NOTE/SUPPLIER JOURNAL"; DebitNoteVM vm = new DebitNoteVM(); vm.DebitNoteNo = AccountsDAO.GetMaxDebiteNoteNo(fyearid); vm.Date = CommanFunctions.GetLastDayofMonth().Date; vm.AcHeadID = 337; vm.TransType = ""; //vm.AmountType = "1"; //vm.AcDetailAmountType = "0"; List <DebitNoteDetailVM> list = new List <DebitNoteDetailVM>(); vm.Details = list; Session["DebitNoteDetail"] = list; return(View(vm)); } else { ViewBag.Title = "DEBIT NOTE/SUPPLIER JOURNAL - Modify"; DebitNoteVM vm = new DebitNoteVM(); var v = db.DebitNotes.Find(id); vm.DebitNoteId = v.DebitNoteID; vm.Date = v.DebitNoteDate; vm.AcJournalID = Convert.ToInt32(v.AcJournalID); vm.DebitNoteNo = v.DebitNoteNo; vm.SupplierID = Convert.ToInt32(v.SupplierID); vm.AcHeadID = Convert.ToInt32(v.AcHeadID); vm.Amount = Convert.ToDecimal(v.Amount); vm.InvoiceType = v.InvoiceType; vm.Remarks = v.Remarks; vm.TransType = v.TransType; vm.InvoiceID = Convert.ToInt32(v.InvoiceID); if (v.RecPayID != null && v.RecPayID != 0) { vm.RecPayID = Convert.ToInt32(v.RecPayID); } else { vm.RecPayID = 0; } var detaillist = (from c in db.DebitNoteDetails join d in db.AcHeads on c.AcHeadID equals d.AcHeadID where c.DebitNoteID == v.DebitNoteID select new DebitNoteDetailVM { AcHeadID = c.AcHeadID, AcHeadName = d.AcHead1, Amount = c.Amount, Remarks = c.Remarks }).ToList(); vm.Details = detaillist; Session["DebitNoteDetail"] = detaillist; SetTradeInvoiceOfSupplier(vm.SupplierID, 0, vm.DebitNoteId, vm.TransType); List <CustomerTradeReceiptVM> lst = (List <CustomerTradeReceiptVM>)Session["SupplierInvoice"]; if (v.TransType == "DN") { if (v.InvoiceType == "TR") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault(); //var invoice = db.SupplierInvoices.Find(vm.InvoiceID); if (invoice != null) { vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.AmountPaid = Convert.ToDecimal(invoice.AmountReceived); } } else if (v.InvoiceType == "OP") { var invoice1 = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault(); //var invoice1 = db.AcOPInvoiceDetails.Where(cc => cc.AcOPInvoiceDetailID == vm.InvoiceID).FirstOrDefault(); if (invoice1 != null) { vm.InvoiceNo = invoice1.InvoiceNo; vm.InvoiceDate = invoice1.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice1.InvoiceAmount); vm.AmountPaid = Convert.ToDecimal(invoice1.AmountReceived); } } } else if (v.RecPayID != null && v.RecPayID != 0 && v.TransType == "SJ") { vm.InvoiceID = Convert.ToInt32(v.RecPayID); vm.InvoiceType = v.InvoiceType; vm.ForInvoice = true; if (v.InvoiceType == "TR") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault(); if (invoice != null) { vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.AmountPaid = Convert.ToDecimal(invoice.AmountReceived); } } else if (v.InvoiceType == "OP") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault(); vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.AmountPaid = Convert.ToDecimal(invoice.AmountReceived); } } else { vm.ForInvoice = false; } //SetTradeInvoiceOfCustomer(vm.CustomerID, 0, vm.CreditNoteID); vm.Date = Convert.ToDateTime(v.DebitNoteDate); return(View(vm)); } }
public ActionResult Create(DebitNoteVM v) { var userid = Convert.ToInt32(Session["UserID"]); int BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); AcJournalMaster ajm = new AcJournalMaster(); int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); if (v.DebitNoteId > 0) { ajm = db.AcJournalMasters.Find(v.AcJournalID); var ajmd = db.AcJournalDetails.Where(cc => cc.AcJournalID == v.AcJournalID).ToList(); db.AcJournalDetails.RemoveRange(ajmd); db.AcJournalMasters.Remove(ajm); db.SaveChanges(); v.AcJournalID = 0; } if (v.AcJournalID == 0) { int acjm = 0; acjm = (from c in db.AcJournalMasters orderby c.AcJournalID descending select c.AcJournalID).FirstOrDefault(); ajm.AcJournalID = acjm + 1; ajm.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); ajm.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); ajm.AcFinancialYearID = fyearid; ajm.PaymentType = 1; var customer = db.SupplierMasters.Find(v.SupplierID).SupplierName; ajm.Remarks = v.Remarks; // + " DN: for " + customer + " invoice : " + v.InvoiceNo; ajm.StatusDelete = false; ajm.VoucherNo = AccountsDAO.GetMaxVoucherNo(v.TransType, fyearid); ajm.TransDate = v.Date; ajm.TransType = 1; ajm.VoucherType = v.TransType; db.AcJournalMasters.Add(ajm); db.SaveChanges(); } AcJournalDetail a = new AcJournalDetail(); a = db.AcJournalDetails.Where(cc => cc.AcJournalID == ajm.AcJournalID && cc.Amount > 0).FirstOrDefault(); if (a == null) { a = new AcJournalDetail(); a.AcJournalDetailID = 0; } if (a.AcJournalDetailID == 0) { int maxacj = (from c in db.AcJournalDetails orderby c.AcJournalDetailID descending select c.AcJournalDetailID).FirstOrDefault(); a.AcJournalDetailID = maxacj + 1; a.AcJournalID = ajm.AcJournalID; //var customercon = db.AcHeads.Where(cc => cc.AcHead1 == "Supplier Control A/c ( Cr)").FirstOrDefault(); a.AcHeadID = 337; //customercon.AcHeadID; ; } a.Amount = v.Amount; a.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); a.Remarks = v.Remarks; if (a.ID == 0) { db.AcJournalDetails.Add(a); db.SaveChanges(); } else { db.Entry(a).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } foreach (var detail in v.Details) { AcJournalDetail b = new AcJournalDetail(); b = db.AcJournalDetails.Where(cc => cc.AcJournalID == ajm.AcJournalID && cc.Amount < 0).FirstOrDefault(); if (b == null) { b = new AcJournalDetail(); b.AcJournalDetailID = 0; } if (b.AcJournalDetailID == 0) { int maxacj = 0; maxacj = (from c in db.AcJournalDetails orderby c.AcJournalDetailID descending select c.AcJournalDetailID).FirstOrDefault(); b.AcJournalDetailID = maxacj + 1; b.AcJournalID = ajm.AcJournalID; } b.AcHeadID = v.AcHeadID; if (v.TransType == "DN") { b.Amount = -1 * detail.Amount; } else { b.Amount = detail.Amount; } b.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); b.Remarks = detail.Remarks; if (b.ID == 0) { db.AcJournalDetails.Add(b); db.SaveChanges(); } else { db.Entry(b).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } DebitNote d = new DebitNote(); if (v.DebitNoteId == 0) { int maxid = 0; var data = (from c in db.DebitNotes orderby c.DebitNoteID descending select c).FirstOrDefault(); if (data == null) { maxid = 1; } else { maxid = data.DebitNoteID + 1; } d.CreatedBy = userid; d.CreatedDate = CommanFunctions.GetCurrentDateTime(); d.DebitNoteID = maxid; d.DebitNoteNo = AccountsDAO.GetMaxDebiteNoteNo(fyearid); } else { d = db.DebitNotes.Find(v.DebitNoteId); var det = db.DebitNoteDetails.Where(cc => cc.DebitNoteID == v.DebitNoteId).ToList(); if (det != null) { db.DebitNoteDetails.RemoveRange(det); db.SaveChanges(); } } d.InvoiceType = v.InvoiceType; d.TransType = v.TransType; if (v.InvoiceID != 0) { if (v.TransType == "DN") { d.InvoiceID = v.InvoiceID; } else { d.RecPayID = v.InvoiceID; } } else { d.InvoiceID = 0; } d.DebitNoteDate = v.Date; d.Amount = v.Amount; d.AcJournalID = ajm.AcJournalID; d.FYearID = Convert.ToInt32(Session["fyearid"].ToString()); d.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); d.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); d.AcHeadID = 527;; d.SupplierID = v.SupplierID; d.ModifiedBy = userid; d.ModifiedDate = CommanFunctions.GetCurrentDateTime(); d.Remarks = v.Remarks; //d.IsShipping = true; if (v.DebitNoteId == 0) { db.DebitNotes.Add(d); db.SaveChanges(); TempData["SuccessMsg"] = "Successfully Added Debit Note"; } else { db.Entry(d).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "Successfully Updated Debit Note"; } foreach (var detail in v.Details) { DebitNoteDetail det = new DebitNoteDetail(); det.AcHeadID = detail.AcHeadID; det.Amount = detail.Amount; det.Remarks = detail.Remarks; det.DebitNoteID = d.DebitNoteID; db.DebitNoteDetails.Add(det); db.SaveChanges(); } return(RedirectToAction("Index", "DebitNote")); }
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; } }