public void AdjustAccountBalance(Guid costCentreId, PaymentMode paymentMode, decimal amount,PaymentNoteType type) { tblPaymentTracker tblpn = _ctx.tblPaymentTracker.FirstOrDefault(n => n.CostCenterId == costCentreId && n.PaymentModeId == (int)paymentMode); if(tblpn==null) { Guid id = Guid.NewGuid(); tblPaymentTracker pnsave = new tblPaymentTracker { Balance = 0, CostCenterId = costCentreId, id = id, PaymentModeId = (int) paymentMode, PendingConfirmBalance = 0, }; _ctx.tblPaymentTracker.AddObject(pnsave); _ctx.SaveChanges(); tblpn = _ctx.tblPaymentTracker.FirstOrDefault(n => n.id == id); } if (type==PaymentNoteType.Availabe ) tblpn.Balance += amount; else if (type == PaymentNoteType.Unavailable) tblpn.PendingConfirmBalance += amount; else if (type ==PaymentNoteType.Returns) { tblpn.Balance += -amount; tblpn.PendingConfirmBalance += (-amount); } _ctx.SaveChanges(); }
public void AdjustAccountBalance(Guid costCentreId, PaymentMode paymentMode, decimal amount, PaymentNoteType type) { _paymentTrackerRepository.AdjustAccountBalance(costCentreId, paymentMode, amount, type); }