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(); }
private PaymentTracker Map(tblPaymentTracker tblAccount) { PaymentTracker acc = new PaymentTracker(tblAccount.id) { CostcentreId = tblAccount.CostCenterId, Balance = (decimal)tblAccount.Balance, PaymentMode = (PaymentMode)tblAccount.PaymentModeId, PendingConfirmBalance = tblAccount.PendingConfirmBalance.Value, }; return acc; }
private PaymentTrackerDTO Map(tblPaymentTracker tbl) { var dto = new PaymentTrackerDTO { MasterId = tbl.id, CostcentreId = tbl.CostCenterId, PaymentModeId = tbl.PaymentModeId, Balance = tbl.Balance.HasValue ? tbl.Balance.Value : 0, PendingConfirmBalance = tbl.PendingConfirmBalance.HasValue?tbl.PendingConfirmBalance.Value:0 }; return dto; }
/// <summary> /// Deprecated Method for adding a new object to the tblPaymentTracker EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotblPaymentTracker(tblPaymentTracker tblPaymentTracker) { base.AddObject("tblPaymentTracker", tblPaymentTracker); }
/// <summary> /// Create a new tblPaymentTracker object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="costCenterId">Initial value of the CostCenterId property.</param> /// <param name="paymentModeId">Initial value of the PaymentModeId property.</param> public static tblPaymentTracker CreatetblPaymentTracker(global::System.Guid id, global::System.Guid costCenterId, global::System.Int32 paymentModeId) { tblPaymentTracker tblPaymentTracker = new tblPaymentTracker(); tblPaymentTracker.id = id; tblPaymentTracker.CostCenterId = costCenterId; tblPaymentTracker.PaymentModeId = paymentModeId; return tblPaymentTracker; }
public void Save(PaymentTracker paymentTracker) { tblPaymentTracker tblpn = _ctx.tblPaymentTracker.FirstOrDefault(n => n.id == paymentTracker.Id); if (tblpn == null) { tblpn = new tblPaymentTracker(); tblpn.id = paymentTracker.Id; _ctx.tblPaymentTracker.AddObject(tblpn); } tblpn.Balance = paymentTracker.Balance; tblpn.CostCenterId = paymentTracker.CostcentreId; tblpn.PaymentModeId = (int) paymentTracker.PaymentMode; tblpn.PendingConfirmBalance = paymentTracker.PendingConfirmBalance; _ctx.SaveChanges(); }