public List <LoanLedger> UpdateLoanLedger(string RefNum, double LoanAmt) { try { // var resp = (from a in uvDb.LoanLedgers where a.RefNumber == RefNum select a).ToList(); var resp = SelectLoanLedger(RefNum, LoanAmt); var Firstrecord = resp.First(); if (Firstrecord != null) { Firstrecord.Credit = LoanAmt; Firstrecord.PaymentFlag_FK = 1; uvDb.SaveChanges(); } var query = "UPDATE LoanLedger SET PaymentFlag_FK = 2 WHERE RefNumber = '" + RefNum + "' AND Credit = 0"; using (var context = new UvlotEntities()) { context.Database.ExecuteSqlCommand(query); } if (resp == null) { return(null); } return(resp.ToList()); } catch (Exception ex) { WebLog.Log(ex.Message.ToString()); return(null); } }
public int UpdateLoanLedgers(string RefNum) { try { var original = (from a in uvDb.LoansLedgers where a.RefNumber == RefNum select a).FirstOrDefault(); if (original != null) { var query = "UPDATE LoansLedger SET IsVisible = 0 WHERE RefNumber = '" + RefNum + "' AND Credit = 0"; using (var context = new UvlotEntities()) { context.Database.ExecuteSqlCommand(query); } // original.IsVisible = 0; // uvDb.SaveChanges(); } return(original.ID); } catch (Exception ex) { WebLog.Log(ex.Message.ToString()); return(0); } }