public ValidationMsg CloseLoanData(EXPBankLoan model, int userid) { _vmMsg = new ValidationMsg(); try { using (var tx = new TransactionScope()) { using (_context) { if (model.expBankLoanList[0].BankLoanID != 0 && model.RecordStatus == "NCF") { foreach (var bankLoan in model.expBankLoanList) { EXP_BankLoan tblBankLoan = SetToBankLoanEntityObject(bankLoan, userid); tblBankLoan.RunningStatus = "CLS"; _context.SaveChanges(); } } _vmMsg.Type = Enums.MessageType.Success; _vmMsg.Msg = "Loan Closed Successfully."; } } } catch { _vmMsg.Type = Enums.MessageType.Error; _vmMsg.Msg = "Failed to Close Loan."; } return(_vmMsg); }
public EXP_BankLoan SetToBankLoanEntityObject(EXPBankLoan model, int _userid)//int _userid { EXP_BankLoan entity = new EXP_BankLoan(); entity.BankLoanID = model.BankLoanID; entity.BankLoanNo = model.BankLoanNo; //entity.BankID = model.BankID; //entity.BranchID = model.BranchID; entity.LoanHead = model.LoanHead; entity.RefACNo = model.RefACNo; entity.RefACName = model.RefACName; var GridloanRecieveDate = model.LoanReceiveDate.Contains("/") ? model.LoanReceiveDate : Convert.ToDateTime(model.LoanReceiveDate).ToString("dd/MM/yyyy"); entity.LoanReceiveDate = DalCommon.SetDate(GridloanRecieveDate); entity.LoanAmt = model.LoanAmt; entity.InterestPercent = model.InterestPercent; entity.LoanLimit = model.LoanLimit; entity.ReturnedAmt = model.ReturnedAmt; entity.BalanceAmt = model.BalanceAmt; entity.CIID = model.CIID; entity.Remarks = model.Remarks; entity.RecordStatus = "NCF"; entity.RunningStatus = "CLS"; entity.SetOn = DateTime.Now; entity.SetBy = _userid; entity.IPAddress = GetIPAddress.LocalIPAddress(); return(entity); }
// ##################### Search END ############## //##################### Confirm Data ############# public ActionResult ConfirmRecordStatus(string bankLoanID) { try { if (bankLoanID != "") { EXP_BankLoan ob = objRepository.ExpBankLoanRepository.GetByID(Convert.ToInt32(bankLoanID)); if (ob.RecordStatus == "NCF") { ob.RecordStatus = "CNF"; objRepository.ExpBankLoanRepository.Update(ob); int flag = objRepository.Save(); if (flag == 1) { objValMssg.Type = Enums.MessageType.Success; objValMssg.Msg = "Confirmed Successfully."; } else { objValMssg.Type = Enums.MessageType.Error; objValMssg.Msg = "Confirmed Faild."; } } else { objValMssg.Type = Enums.MessageType.Error; objValMssg.Msg = "Record Status has not found."; } } } catch (DbEntityValidationException e) { StringBuilder sb = new StringBuilder(); foreach (var eve in e.EntityValidationErrors) { sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State)); foreach (var ve in eve.ValidationErrors) { sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } } throw new DbEntityValidationException(sb.ToString(), e); } return(Json(new { msg = objValMssg })); }
public ValidationMsg Save(EXPBankLoan model, int _userid, string pageUrl)//, string pageUrl { _vmMsg = new ValidationMsg(); try { using (var tx = new TransactionScope()) { using (_context) { if (model.expBankLoanList.Count > 0) { foreach (var bankLoan in model.expBankLoanList) { EXP_BankLoan tblBankLoan = SetToBankLoanModelObject(bankLoan, _userid); tblBankLoan.BankID = model.BankID; tblBankLoan.BranchID = model.BranchID; tblBankLoan.ApprovalNote = model.ApprovalNote; _context.EXP_BankLoan.Add(tblBankLoan); _context.SaveChanges(); } } _context.SaveChanges(); tx.Complete(); _vmMsg.Type = Enums.MessageType.Success; _vmMsg.Msg = "Saved Successfully."; } } } catch (DbEntityValidationException e) { _vmMsg.Type = Enums.MessageType.Error; _vmMsg.Msg = "Failed to Save."; } return(_vmMsg); }
public ValidationMsg Update(EXPBankLoan model, int _userid) { _vmMsg = new ValidationMsg(); try { #region Update using (var tx = new TransactionScope()) { using (_context) { #region Save NEW Data & Update Existing Crust Leather Transfer Data if (model.expBankLoanList != null) { foreach (EXPBankLoan bankLoan in model.expBankLoanList) { bankLoan.BankID = model.BankID; bankLoan.BranchID = model.BranchID; bankLoan.ApprovalNote = model.ApprovalNote; if (bankLoan.BankLoanID == 0) { EXP_BankLoan tblBankLoan = SetToBankLoanModelObject(bankLoan, _userid); tblBankLoan.BankID = bankLoan.BankID; tblBankLoan.BranchID = bankLoan.BranchID; tblBankLoan.ApprovalNote = bankLoan.ApprovalNote; _context.EXP_BankLoan.Add(tblBankLoan); } else { EXP_BankLoan bankLoanEntity = SetToBankLoanModelObject(bankLoan, _userid); model.BankID = bankLoanEntity.BankID; model.BranchID = bankLoanEntity.BranchID; model.ApprovalNote = bankLoanEntity.ApprovalNote; var obBankLoan = _context.EXP_BankLoan.First(m => m.BankLoanID == bankLoan.BankLoanID); //obBankLoan.BankLoanID = model.BankLoanID; obBankLoan.BankLoanNo = bankLoanEntity.BankLoanNo; obBankLoan.CIID = bankLoanEntity.CIID; obBankLoan.LoanHead = bankLoanEntity.LoanHead; obBankLoan.RefACNo = bankLoanEntity.RefACNo; obBankLoan.RefACName = bankLoanEntity.RefACName; //var GridloanRecieveDate = bankLoanEntity.LoanReceiveDate.Contains("/") ? bankLoanEntity.LoanReceiveDate : Convert.ToDateTime(bankLoanEntity.LoanReceiveDate).ToString("dd/MM/yyyy"); //obBankLoan.LoanReceiveDate = DalCommon.SetDate(GridloanRecieveDate); obBankLoan.LoanAmt = bankLoanEntity.LoanAmt; obBankLoan.InterestPercent = bankLoanEntity.InterestPercent; obBankLoan.LoanLimit = bankLoanEntity.LoanLimit; obBankLoan.ReturnedAmt = bankLoanEntity.ReturnedAmt; obBankLoan.BalanceAmt = bankLoanEntity.BalanceAmt; obBankLoan.Remarks = bankLoanEntity.Remarks; obBankLoan.RunningStatus = bankLoanEntity.RunningStatus; obBankLoan.RecordStatus = "NCF"; obBankLoan.ModifiedOn = DateTime.Now; obBankLoan.ModifiedBy = _userid; obBankLoan.IPAddress = GetIPAddress.LocalIPAddress(); } } } #endregion _context.SaveChanges(); tx.Complete(); _vmMsg.Type = Enums.MessageType.Update; _vmMsg.Msg = "Updated Successfully."; } } #endregion } catch (DbEntityValidationException e) { _vmMsg.Type = Enums.MessageType.Error; _vmMsg.Msg = "Failed to Update."; } return(_vmMsg); }