public static List <CustomerLoan> GetCustomerActiveLoanList(bool allOffices = false, bool showDeleted = false) { List <CustomerLoan> CustomerActiveLoanList = new List <CustomerLoan>(); List <CustomerLoan> CustomerLoanList = GetCustomerLoanList(allOffices, showDeleted); if (CustomerLoanList.Count > 0) { var ActiveLoanList = (from TheLoanList in CustomerLoanList where TheLoanList.IsClosed == false select TheLoanList); foreach (CustomerLoan EachLoan in ActiveLoanList) { CustomerLoan TheCustomerLoan = (CustomerLoan)EachLoan; CustomerActiveLoanList.Add(TheCustomerLoan); } } return(CustomerActiveLoanList); }
public ActionResult GetLoanDetails(int loanId, int customerId) { if (loanId <= 0 && customerId <= 0) { return(BadRequest("Invalid loan id or customer id")); } if (loanId > 0 && customerId > 0) { CustomerLoan customerLoan = _loanDetailsService.GetLoanDetails(loanId, customerId); if (customerLoan == null) { return(NoContent()); } else { return(Ok(customerLoan)); } } else { return(NoContent()); } }
public int UpdateCustomerLoan(CustomerLoan theCustomerLoan) { int ReturnValue = 0; using (SqlCommand UpdateCommand = new SqlCommand()) { UpdateCommand.CommandType = CommandType.StoredProcedure; UpdateCommand.Parameters.Add(GetParameter("@ReturnValue", SqlDbType.Int, ReturnValue)).Direction = ParameterDirection.Output; UpdateCommand.Parameters.Add(GetParameter("@LoanApplicationNumber", SqlDbType.VarChar, theCustomerLoan.LoanApplicationNumber)); UpdateCommand.Parameters.Add(GetParameter("@LoanApplicationDate", SqlDbType.VarChar, theCustomerLoan.LoanApplicationDate)); UpdateCommand.Parameters.Add(GetParameter("@LoanApplicationFee", SqlDbType.Decimal, theCustomerLoan.LoanApplicationFee)); UpdateCommand.Parameters.Add(GetParameter("@LoanAmount", SqlDbType.Decimal, theCustomerLoan.LoanAmount)); UpdateCommand.Parameters.Add(GetParameter("@RateOfInterest", SqlDbType.Decimal, theCustomerLoan.RateOfInterest)); UpdateCommand.Parameters.Add(GetParameter("@RequiredFor", SqlDbType.VarChar, theCustomerLoan.RequiredFor)); UpdateCommand.Parameters.Add(GetParameter("@ModifiedBy", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.UserID)); UpdateCommand.CommandText = "pCRM_CustomerLoans_Update"; ExecuteStoredProcedure(UpdateCommand); ReturnValue = int.Parse(UpdateCommand.Parameters[0].Value.ToString()); return(ReturnValue); } }
public async Task <IActionResult> AssignLoan([FromForm] LoanRequestVM loanrequest) { List <CustomerLoanDocumentDtl> lstLoanDocument = new List <CustomerLoanDocumentDtl>(); string folderName = "CustomerDoc"; var currentUser = HttpContext.User; Int32 userId = Convert.ToInt32(currentUser.Claims.FirstOrDefault(c => c.Type == "user_id").Value); try { CustomerLoan objCustomerLoan = new CustomerLoan(); var loan = JsonConvert.DeserializeObject <LoadDetailVM>(loanrequest.loandetail); if (loan != null) { objCustomerLoan = _mapper.Map <CustomerLoan>(loan); objCustomerLoan.CreatedBy = userId; objCustomerLoan.AgentId = userId; objCustomerLoan.CreatedDate = DateTime.Now; _context.CustomerLoan.Add(objCustomerLoan); _context.SaveChanges(); #region CustomerLoanTxn if (loan.lsttenure != null && loan.lsttenure.Count > 0) { if (objCustomerLoan.CustomerLoanId > 0) { List <CustomerLoanTxn> lstCustomerLoanTxn = new List <CustomerLoanTxn>(); lstCustomerLoanTxn = _mapper.Map <List <CustomerLoanTxn> >(loan.lsttenure); foreach (var tenure in lstCustomerLoanTxn) { tenure.CreatedBy = userId; tenure.CreatedDate = DateTime.Now; tenure.CustomerLoanId = objCustomerLoan.CustomerLoanId; _context.CustomerLoanTxn.Add(tenure); _context.SaveChanges(); } } } #endregion #region AgentBalanceMst AgentBalanceMst objAgentBalanceMst = _context.AgentBalanceMst.FirstOrDefault(x => x.AgentId == userId); if (objAgentBalanceMst != null) { objAgentBalanceMst.Lb = objAgentBalanceMst.Lb - loan.LoanAmount; objAgentBalanceMst.UpdatedBy = userId; objAgentBalanceMst.UpdatedDate = DateTime.Now; _context.Entry(objAgentBalanceMst).State = EntityState.Modified; _context.SaveChanges(); } #endregion #region Upload Customer Loan Doc if (loanrequest.uploadDoc != null) { foreach (var file in loanrequest.uploadDoc) { CustomerLoanDocumentDtl docDtl = new CustomerLoanDocumentDtl(); if (file.filedata == null && !string.IsNullOrEmpty(file.Filename)) { //return BadRequest("Empty File"); docDtl.CustomerLoanId = objCustomerLoan.CustomerLoanId; docDtl.DocumentTypeId = file.DocType; docDtl.FileName = file.Filename; docDtl.UploadedDate = DateTime.Now; docDtl.UploadedBy = userId; lstLoanDocument.Add(docDtl); } else if (file.filedata != null) { //if (file.Length > 2 * 1024 * 1024) return BadRequest("Max file size exceeded."); string webRootPath = _hostingEnvironment.WebRootPath; string uploadFilesPath = Path.Combine(webRootPath, folderName); if (!Directory.Exists(uploadFilesPath)) { Directory.CreateDirectory(uploadFilesPath); } var fileName = Path.GetFileNameWithoutExtension(file.filedata.FileName) + "-" + Guid.NewGuid().ToString() + Path.GetExtension(file.filedata.FileName); var filePath = Path.Combine(uploadFilesPath, fileName); using (var stream = new FileStream(filePath, FileMode.Create)) { await file.filedata.CopyToAsync(stream); } docDtl.CustomerLoanId = objCustomerLoan.CustomerLoanId; docDtl.DocumentTypeId = file.DocType; docDtl.FileName = fileName; docDtl.UploadedDate = DateTime.Now; docDtl.UploadedBy = userId; lstLoanDocument.Add(docDtl); } else { break; } } _context.CustomerLoanDocumentDtl.AddRange(lstLoanDocument); _context.SaveChanges(); } #endregion } } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.ExpectationFailed)); } return(Ok(new { success = true })); }
public int DeleteCustomerLoan(CustomerLoan theCustomerLoan) { return(CustomerLoanIntegration.DeleteCustomerLoan(theCustomerLoan)); }
public int UpdateCustomerLoan(CustomerLoan theCustomerLoan) { return(CustomerLoanIntegration.UpdateCustomerLoan(theCustomerLoan)); }
public int InsertCustomerLoan(CustomerLoan theCustomerLoan) { return(CustomerLoanIntegration.InsertCustomerLoan(theCustomerLoan)); }
public static int DeleteCustomerLoan(CustomerLoan theCustomerLoan) { return(CustomerLoanDataAccess.GetInstance.DeleteCustomerLoan(theCustomerLoan)); }
public static int InsertCustomerLoan(CustomerLoan theCustomerLoan) { return(CustomerLoanDataAccess.GetInstance.InsertCustomerLoan(theCustomerLoan)); }