/// <summary> /// CreatedBy : Nadeeka /// CreatedDate: 2016/03/15 /// /// Get loan curtailment schedule by loan id /// /// </summary> /// <param name="loanId">loan id</param> /// <returns>curtialment breakdown as a DataSet</returns> public LoanSetupStep1 GetLoanCurtailmentBreakdown(int loanId) { DataHandler dataHandler = new DataHandler(); List <object[]> paramertList = new List <object[]>(); paramertList.Add(new object[] { "@loan_id", loanId }); DataSet dataSet = dataHandler.GetDataSet("spGetLoanCurtailmentBreakdown", paramertList); if (dataSet != null && dataSet.Tables.Count != 0) { LoanSetupStep1 loan = new LoanSetupStep1(); loan.curtailmetList = new List <Curtailment>(); loan.payOffPeriodType = dataSet.Tables[0].Rows[0]["pay_off_type"].ToString().Equals("d") ? 0 : 1; //loan.payOffPeriod = Convert.ToInt32(dataSet.Tables[0].Rows[0]["pay_off_period"].ToString()); loan.CurtailmentCalculationBase = dataSet.Tables[0].Rows[0]["curtailment_calculation_type"].ToString(); loan.advancePercentage = Convert.ToInt32(dataSet.Tables[0].Rows[0]["advance"].ToString()); foreach (DataRow dataRow in dataSet.Tables[0].Rows) { Curtailment curtailment = new Curtailment(); curtailment.CurtailmentId = Convert.ToInt32(dataRow["curtailment_id"].ToString()); curtailment.TimePeriod = Convert.ToInt32(dataRow["time_period"].ToString()); curtailment.Percentage = Convert.ToInt32(dataRow["percentage"].ToString()); loan.curtailmetList.Add(curtailment); } return(loan); } else { return(null); } }
/// <summary> /// CreatedBy:kasun /// CreatedDate:2016/3/21 /// Search for payoff units /// </summary> /// <param name="identificationNumber"></param> /// <param name="year"></param> /// <param name="make"></param> /// <param name="vehicleModel"></param> /// <returns></returns> public ActionResult SearchUnit(string identificationNumber, string year, string make, string vehicleModel) { string loanCode; try { loanCode = Session["loanCode"].ToString(); } catch (Exception) { return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." })); } LoanSetupStep1 loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); ViewBag.loanDetails = loanDetails; List <UnitPayOffModel> unitList = (List <UnitPayOffModel>)Session["payoffList"]; UnitPayOffViewModel unitListMain = new UnitPayOffViewModel(); unitListMain.UnitPayOffList = new List <UnitPayOffModel>(); if (((!string.IsNullOrEmpty(identificationNumber)) || (!string.IsNullOrEmpty(year)) || (!string.IsNullOrEmpty(make)) || (!string.IsNullOrEmpty(vehicleModel)))) { //search through list elements Search sc = new Search(); unitListMain.SearchList = sc.GetSearchPayOffList(unitList, identificationNumber.Trim().ToLower(), year.Trim().ToLower(), make.Trim().ToLower(), vehicleModel.Trim().ToLower()); return(PartialView(unitListMain)); } unitListMain.SearchList = new List <UnitPayOffModel>(); return(PartialView(unitListMain)); }
/* * * Frontend page: Curtailment Page * Title: Curtailments by selected due date * Designed: Nadeeka * User story: * Developed: Nadeeka * Date created: 3/21/2016 * */ public ActionResult PayCurtailmentForSelectedDueDate(DateTime dueDate) { CurtailmentScheduleModel curtailmentScheduleModel = new CurtailmentScheduleModel(); LoanSetupStep1 loanDetails = new LoanSetupStep1(); loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(Session["loanCode"].ToString()); // take loan details of selected loan ViewBag.loanDetails = loanDetails; string f = dueDate.ToShortDateString(); DateTime dd = Convert.ToDateTime(f); CurtailmentAccess curtailmentAccess = new CurtailmentAccess(); List <CurtailmentShedule> curtailmentSchedule = curtailmentAccess.GetCurtailmentScheduleByDueDate(loanDetails.loanId, dd); // get curtailment list by due date ViewBag.DealerEmail = (string)Session["DealerEmail"]; // pass dealer email to the view ViewBag.LoanId = loanDetails.loanId; // pass loan id to the view curtailmentScheduleModel.CurtailmentScheduleInfoModel = new List <CurtailmentShedule>(); curtailmentScheduleModel.CurtailmentScheduleInfoModel.AddRange(curtailmentSchedule); // bind the list of curtailment to model curtailmentScheduleModel.DueDate = dueDate; // bind the due date to model // return the partial view page return(PartialView(curtailmentScheduleModel)); }
/* * * Frontend page: Fee Page * Title: get fees by selected date * Designed: Nadeeka * User story: * Developed: Nadeeka * Date created: 4/21/2016 * */ public ActionResult PayFeesForSelectedDueDate(DateTime dueDate, string type) { LoanSetupStep1 loanDetails = new LoanSetupStep1(); loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(Session["loanCode"].ToString()); // take the loan detail of selected loan // pass the loan details to the view ViewBag.loanDetails = loanDetails; FeeAccess feeAccess = new FeeAccess(); List <Fees> lstFee = feeAccess.GetFeesByDueDate(loanDetails.loanId, dueDate, type); // get fees list by duedate and type of fee FeesModel feeModel = new FeesModel(); feeModel.FeeModelList = new List <Fees>(); feeModel.Type = type; // if list exists, add to model and session for searching if (lstFee != null && lstFee.Count > 0) { feeModel.FeeModelList.AddRange(lstFee); Session["feeList"] = feeModel.FeeModelList; } // return partial view of selected fee page return(PartialView(feeModel)); }
public FileResult PrintPage() { if (Session["addUnitloan"] == null) { return(null); } LoanSetupStep1 loan = (LoanSetupStep1)Session["addUnitloan"]; Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; RptDivAddUnit justAddedUnitReport = new RptDivAddUnit(); var rptViewerPrint = justAddedUnitReport.PrintPage(loan.loanId, userData.UserId); var bytes = rptViewerPrint.LocalReport.Render( "PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); var fsResult = File(bytes, "application/pdf"); return(fsResult); }
public ActionResult LoanPaymentDetails() { int userId; string loanCode; try { userId = userData.UserId; loanCode = Session["loanCode"].ToString(); } catch (Exception) { return(RedirectToAction("UserLogin", "Login")); } //int userId = 57; LoanSetupStep1 loanSetupStep1 = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); LoanPaymentDetails advance = (new UnitAccess()).GetLoanPaymentDetailsByLoanId(loanSetupStep1.loanId); ViewBag.AvailableBalance = advance.Amount - advance.UsedAmount; return(PartialView(advance)); }
public int PayFees(List <Fees> lstFee, string type) { int userId = userData.UserId; // set the user id FeeAccess feeAccess = new FeeAccess(); LoanSetupStep1 loanDetails = new LoanSetupStep1(); loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(Session["loanCode"].ToString()); // take the loan details by loan code int returnValue = feeAccess.updateFees(lstFee, lstFee[0].PaidDate, loanDetails.loanId, userId); // update fee details //if successfully updated, insert to log if (returnValue == 1) { Log log; // if fee type is advance -- save details to log as advance fee if (type == "advanceFee") { List <string> IDNumbers = new List <string>(); foreach (var fee in lstFee) { IDNumbers.Add(fee.IdentificationNumber); } log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanDetails.loanId, "Pay Fees", "Advance Fee Paid for the unit(s) : " + string.Join(",", IDNumbers) + " , Pay Date : " + lstFee[0].PaidDate.ToString("dd/MM/yyyy"), DateTime.Now); (new LogAccess()).InsertLog(log); } // if fee type is monthly loan -- save details to log as monthly loan fee else if (type == "monthlyLoanFee") { List <string> DueDates = new List <string>(); foreach (var fee in lstFee) { DueDates.Add(fee.DueDate); } log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanDetails.loanId, "Pay Fees", " Monthly Loan Fee Paid for the due date(s) : { " + string.Join(",", DueDates) + "}" + ", Pay Date : " + lstFee[0].PaidDate.ToString("dd/MM/yyyy"), DateTime.Now); (new LogAccess()).InsertLog(log); } // if fee type is lot inspection fee -- save details to log as lot inspection fee else if (type == "lotInspectionFee") { List <string> DueDates = new List <string>(); foreach (var fee in lstFee) { DueDates.Add(fee.DueDate); } log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanDetails.loanId, "Pay Fees", "Lot Inspection Fee Paid for the due date(s) : { " + string.Join(",", DueDates) + " } " + ", Pay Date : " + lstFee[0].PaidDate.ToString("dd/MM/yyyy"), DateTime.Now); (new LogAccess()).InsertLog(log); } } // return the value to view return(returnValue); }
public JsonResult IsVinExists(string identificationNumber) { LoanSetupStep1 loan = (LoanSetupStep1)Session["addUnitloan"]; //check user name is already exist. int loanId = loan.loanId; int num = (new UnitAccess()).IsUniqueVinForaLoan(identificationNumber, loanId); return(Json(num, JsonRequestBehavior.AllowGet)); }
/* * Frontend page: Update Titles * Title: Update title status * Designed: Piyumi * User story: * Developed: Piyumi * Date created: 03/17/2016 */ public int UpdateTitleStatus(Models.Unit unitTitle) { string loanCode = null; //Check Session["loanCode"] is null or empty if (!string.IsNullOrEmpty(Session["loanCode"].ToString())) { //if not null or empty convert session to string variable loanCode = Session["loanCode"].ToString(); } TitleAccess titleObj = new TitleAccess(); //update title status bool reslt = titleObj.UpdateTitle(unitTitle, loanCode, userData.UserId); //Check result of update title if (reslt) { //if result is true get loan details by loan code LoanSetupStep1 loanDetails = new LoanSetupStep1(); loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); string status = ""; //Check title status //TitleStatus 0 - Not received if (unitTitle.TitleStatus == 0) { status = "Not Received"; } //TitleStatus 1 - Received else if (unitTitle.TitleStatus == 1) { status = "Received"; } //TitleStatus 2 - Returned to Dealer else if (unitTitle.TitleStatus == 2) { status = "Returned to Dealer"; } //TitleStatus 3 - Sent to Bank else if (unitTitle.TitleStatus == 3) { status = "Sent to Bank"; } //insert log entry Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanDetails.loanId, "Title Status Update", "Update title status of unit:" + unitTitle.IdentificationNumber + " ,Updated status:" + status + ",Updated date:" + DateTime.Now, DateTime.Now); int islog = (new LogAccess()).InsertLog(log); TempData["reslt"] = 1; return(1); } else { TempData["reslt"] = 0; return(0); } }
public ActionResult LoanInfo(string title, string msg) { ViewBag.Msg = msg; int userId; string loanCode = null; try { userId = userData.UserId; } catch (Exception) { return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." })); } if (Session["loanCode"] != null) { loanCode = Session["loanCode"].ToString(); } ViewBag.Title = title; ViewBag.Username = userData.UserName; BranchAccess ba = new BranchAccess(); ViewBag.roleId = userData.RoleId; // get the Company type for front end view int comType = ba.getCompanyTypeByUserId(userId); ViewBag.loanCompanyType = (comType == 1) ? "Dealer" : "Lender"; if (loanCode != null) { LoanSetupStep1 loan = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); Session["addUnitloan"] = loan; NonRegBranch nonRegBranch = ba.getNonRegBranchByNonRegBranchId(loan.nonRegisteredBranchId); ViewBag.NonRegBranchName = nonRegBranch.BranchName; //dealer email address, this will be used on curtailment page Session["DealerEmail"] = nonRegBranch.BranchEmail; ViewBag.loanBranchAddress = (nonRegBranch.BranchAddress1 != "" ? nonRegBranch.BranchAddress1 : "") + (nonRegBranch.BranchAddress2 != "" ? ", " + nonRegBranch.BranchAddress2 : "") + (nonRegBranch.BranchCity != "" ? ", " + nonRegBranch.BranchCity : ""); ViewBag.CurtailmentDueDate = loan.CurtailmentDueDate; ViewBag.LoanNumber = loan.loanNumber; } return(View()); }
public ActionResult AddUnitReport() { if (Session["addUnitloan"] == null) { return(RedirectToAction("UserLogin", "Login", new { lbl = "Failed find loan" })); } LoanSetupStep1 loan = (LoanSetupStep1)Session["addUnitloan"]; ViewBag.LoanId = loan.loanId; ViewBag.UserId = userData.UserId; return(View()); }
/// <summary> /// CreatedBy : Nadeeka /// CreatedDate: 2016/02/09 /// /// Insert curtailment details /// /// argument : curtailment list /// /// </summary> /// <returns>1</returns> public LoanSetupStep1 GetLoanDetailsByLoanId(int loanId) { try { LoanSetupStep1 loan = new LoanSetupStep1(); DataHandler dataHandler = new DataHandler(); List <object[]> paramertList = new List <object[]>(); paramertList.Add(new object[] { "@loan_id", loanId }); DataSet dataSet = dataHandler.GetDataSet("spGetLoanDetailsByLoanId", paramertList); if (dataSet != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows.Count != 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; loan.loanNumber = dataRow["loan_number"].ToString(); loan.startDate = Convert.ToDateTime(dataRow["start_date"]); loan.maturityDate = Convert.ToDateTime(dataRow["maturity_date"]); loan.loanAmount = Convert.ToDecimal(dataRow["loan_amount"]); loan.advancePercentage = Convert.ToInt32(dataRow["advance"]); //0 - day, 1 - month loan.payOffPeriodType = 1; if (dataRow["pay_off_type"].ToString() == "d") { loan.payOffPeriodType = 0; } //loan.payOffPeriod = Convert.ToInt32(dataRow["pay_off_period"]); loan.LoanStatus = Convert.ToBoolean(dataRow["loan_status"]); loan.isInterestCalculate = Convert.ToBoolean(dataRow["is_interest_calculate"]); loan.isEditAllowable = Convert.ToBoolean(dataRow["is_edit_allowable"]); loan.CurtailmentDueDate = dataRow["curtailment_due_date"].ToString(); loan.CurtailmentAutoRemindEmail = dataRow["curtailment_auto_remind_email"].ToString(); if (!string.IsNullOrEmpty(dataRow["curtailment_remind_period"].ToString())) { loan.CurtailmentEmailRemindPeriod = Convert.ToInt32(dataRow["curtailment_remind_period"].ToString()); } loan.CurtailmentCalculationBase = dataRow["curtailment_calculation_type"].ToString(); return(loan); } else { return(null); } } catch (Exception ex) { throw ex; } }
/// <summary> /// CreatedBy : iRFAN /// CreatedDate: 2016/02/25 /// /// GET LOAN DETAILS BY NON REG BRANCH ID /// /// /// /// </summary> /// <returns>1</returns> public List <LoanSetupStep1> GetLoanDetailsByNonRegBranchId(int nonRegBranchId) { List <LoanSetupStep1> loanList = new List <LoanSetupStep1>(); DataHandler dataHandler = new DataHandler(); List <object[]> paramertList = new List <object[]>(); paramertList.Add(new object[] { "@non_reg_branch_id", nonRegBranchId }); try { DataSet dataSet = dataHandler.GetDataSet("spGetLoanDetailsByNonRegBranchId", paramertList); if (dataSet != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows.Count != 0) { foreach (DataRow dataRow in dataSet.Tables[0].Rows) { LoanSetupStep1 loan = new LoanSetupStep1(); loan.loanNumber = dataRow["loan_number"].ToString(); loan.startDate = Convert.ToDateTime(dataRow["start_date"]); loan.maturityDate = Convert.ToDateTime(dataRow["maturity_date"]); loan.loanAmount = Convert.ToDecimal(dataRow["loan_amount"]); loan.advancePercentage = Convert.ToInt32(dataRow["advance"]); //0 - day, 1 - month if (dataRow["pay_off_type"].ToString() == "d") { loan.payOffPeriodType = 0; } loan.payOffPeriodType = 1; //loan.payOffPeriod = Convert.ToInt32(dataRow["pay_off_period"]); loan.LoanStatus = Convert.ToBoolean(dataRow["loan_status"]); loan.loanCode = dataRow["loan_code"].ToString(); loan.isEditAllowable = Convert.ToBoolean(dataRow["is_edit_allowable"]); loanList.Add(loan); } } return(loanList); } catch (Exception ex) { throw ex; } }
/// <summary> /// Frontend page: Advance Unit(Search section) /// Title: get unit list which match with given search parameters /// Designed: Piyumi Perera /// User story: /// Developed: Piyumi Perera /// Date created: 02/27/2016 /// </summary> /// <param name="identificationNumber"></param> /// <param name="year"></param> /// <param name="make"></param> /// <param name="vehicleModel"></param> /// <returns></returns> public ActionResult SearchUnit(string identificationNumber, string year, string make, string vehicleModel) { string loanCode; try { //convert session to string variable loanCode = Session["loanCode"].ToString(); } catch (Exception) { //if exception occured return to login page return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." })); } //get loan details for given loan code LoanSetupStep1 loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); ViewBag.loanDetails = loanDetails; //convert Session["notAdvancedList"] to list object List <Models.Unit> unitList = (List <Models.Unit>)Session["notAdvancedList"]; Models.AdvanceUnit unitListMain = new Models.AdvanceUnit(); unitListMain.NotAdvanced = new List <Models.Unit>(); //check atleast one parameter is not null or empty if (((!string.IsNullOrEmpty(identificationNumber)) || (!string.IsNullOrEmpty(year)) || (!string.IsNullOrEmpty(make)) || (!string.IsNullOrEmpty(vehicleModel)))) { //search through list elements Search sc = new Search(); //get result list of search unitListMain.Search = sc.GetSearchResultsList(unitList, identificationNumber.Trim().ToLower(), year.Trim().ToLower(), make.Trim().ToLower(), vehicleModel.Trim().ToLower()); //return result list in to partial view return(PartialView(unitListMain)); } else { //create empty list if all search parameters are null or empty unitListMain.Search = new List <Models.Unit>(); //return list to partial view return(PartialView(unitListMain)); } }
public ActionResult GetJustAddedUnits() { int userId; string loanCode; try { userId = userData.UserId; loanCode = Session["loanCode"].ToString(); ViewBag.UserRole = userData.RoleId; } catch (Exception) { return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." })); } //int userId = 57; LoanSetupStep1 loanSetupStep1 = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); return(PartialView((new UnitAccess().GetJustAddedUnitDetails(userId, loanSetupStep1.loanId)))); }
public ActionResult AddUnitPost(Models.Unit unit, List <HttpPostedFileBase> fileUpload) { int userId = userData.UserId; // check this is an advance or add unit switch (unit.AdvanceNow) { case "No": unit.IsAdvanced = false; unit.AddAndAdvance = false; break; case "Yes": unit.IsAdvanced = true; unit.AddAndAdvance = true; break; } if (Session["loanCode"] == null) { return(RedirectToAction("UserLogin", "Login", null)); } string loanCode = Session["loanCode"].ToString(); //check this posted vin unique in database int num = 0; // vehile ID number if (unit.UnitTypeId == 1) { num = (new UnitAccess()).IsUniqueVinForaLoan(unit.vehicle.IdentificationNumber, unit.LoanId); } // rv ID number else if (unit.UnitTypeId == 2) { num = (new UnitAccess()).IsUniqueVinForaLoan(unit.rv.IdentificationNumber, unit.LoanId); } // camper ID number else if (unit.UnitTypeId == 3) { num = (new UnitAccess()).IsUniqueVinForaLoan(unit.camper.IdentificationNumber, unit.LoanId); } // atv ID number else if (unit.UnitTypeId == 4) { num = (new UnitAccess()).IsUniqueVinForaLoan(unit.atv.IdentificationNumber, unit.LoanId); } // boat ID number else if (unit.UnitTypeId == 5) { num = (new UnitAccess()).IsUniqueVinForaLoan(unit.boat.IdentificationNumber, unit.LoanId); } // motorcycle ID number else if (unit.UnitTypeId == 6) { num = (new UnitAccess()).IsUniqueVinForaLoan(unit.motorcycle.IdentificationNumber, unit.LoanId); } // snowmobile ID number else if (unit.UnitTypeId == 7) { num = (new UnitAccess()).IsUniqueVinForaLoan(unit.snowmobile.IdentificationNumber, unit.LoanId); } // heavyequipment ID number else if (unit.UnitTypeId == 8) { num = (new UnitAccess()).IsUniqueVinForaLoan(unit.heavyequipment.SerialNumber, unit.LoanId); } //only allow to add if and only if vin already not existing in this loan if (num != 0 && num != 1) { string IDNumber; UnitAccess ua = new UnitAccess(); //inserting the unit to the database string res = ua.InsertUnit(unit, userId, loanCode, out IDNumber); //if mention advance fee, then insert in to fee table if (!string.IsNullOrEmpty(res) && unit.AddAndAdvance) { if ((Session["loanDashboard"] != null) || (Session["oneLoanDashboard"] != null)) { Loan loanObj = new Loan(); if (Session["loanDashboard"] != null) { loanObj = (Loan)Session["loanDashboard"]; } else { loanObj = (Loan)Session["oneLoanDashboard"]; } if (loanObj.AdvanceFee == 1) { //check advance amount and other details ua.insertFreeDetails(unit); } } } if (!string.IsNullOrEmpty(res)) { if (Session["addUnitloan"] == null) { return(RedirectToAction("UserLogin", "Login", new { lbl = "Failed find loan" })); } LoanSetupStep1 loan = (LoanSetupStep1)Session["addUnitloan"]; //insert to log Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, unit.LoanId, "Add Unit", (unit.AddAndAdvance ? "Added and advanced" : "Added") + " unit : " + IDNumber + ", Cost Amount : " + unit.Cost + (unit.Cost * loan.advancePercentage / 100 != unit.AdvanceAmount ? ", Edited Advance amount " + unit.AdvanceAmount : ", Advance amount : " + unit.AdvanceAmount), DateTime.Now); int islog = (new LogAccess()).InsertLog(log); //Handling file attachments //Check directory is already exists, if not create new string mapPath = "~/Uploads/" + loan.RegisteredCompanyCode + "/" + loan.RegisteredBranchCode + "/"; if (!Directory.Exists(Server.MapPath(mapPath))) { Directory.CreateDirectory(Server.MapPath(mapPath)); } List <TitleUpload> titleList = new List <TitleUpload>(); int imageNo = 1; // if unit successfully updated then upload files if (unit.FileName != null && fileUpload != null) { foreach (var file in fileUpload) { if (file != null && Array.Exists(unit.FileName.Split(','), s => s.Equals(file.FileName))) { if (file.ContentLength > 3 * 1024 * 1024) { break; } unit.UnitId = res; string extension = Path.GetExtension(file.FileName); string filename = unit.UnitId + "_" + imageNo.ToString("00") + extension; file.SaveAs(Server.MapPath(mapPath + filename)); string filepathtosave = mapPath + filename; //add file information to list TitleUpload title = new TitleUpload(); title.UploadId = imageNo; title.FilePath = filepathtosave; title.UnitId = unit.UnitId; title.OriginalFileName = file.FileName; titleList.Add(title); imageNo++; } } try { XElement xEle = new XElement("Titles", from title in titleList select new XElement("Title", new XElement("FilePath", title.FilePath), new XElement("UnitId", title.UnitId), new XElement("OriginalFileName", title.OriginalFileName) )); string xmlDoc = xEle.ToString(); bool res1 = ua.InsertTitleDocumentUploadInfo(xmlDoc, unit.UnitId); } catch (Exception ex) { throw ex; } } TempData["Msg"] = 1; return(RedirectToAction("AddUnit")); } } TempData["Msg"] = 2; return(RedirectToAction("AddUnit", unit)); }
/// <summary> /// CreatedBy: Kanishka /// CreatedDate:02/29/2016 /// get loan details by loan code /// </summary> /// <param name="loanCode"></param> /// <returns></returns> internal LoanSetupStep1 GetLoanDetailsByLoanCode(string loanCode) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["AutoDealersConnection"].ConnectionString)) { try { using (SqlCommand cmd = new SqlCommand("spGetLoanDetailsByLoanCode", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@loan_code", SqlDbType.VarChar).Value = loanCode; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); LoanSetupStep1 loanSetupStep1 = new LoanSetupStep1(); while (reader.Read()) { loanSetupStep1.loanId = Convert.ToInt32(reader["loan_id"]); loanSetupStep1.advancePercentage = int.Parse(reader["advance"].ToString()); loanSetupStep1.autoReminderEmail = reader["auto_remind_email"].ToString(); loanSetupStep1.autoReminderPeriod = int.Parse(reader["auto_remind_period"].ToString()); loanSetupStep1.defaultUnitType = int.Parse(reader["default_unit_type"].ToString()); loanSetupStep1.isEditAllowable = Convert.ToBoolean(reader["is_edit_allowable"].ToString()); loanSetupStep1.isInterestCalculate = Convert.ToBoolean(reader["is_interest_calculate"].ToString()); loanSetupStep1.loanAmount = Convert.ToDecimal(reader["loan_amount"].ToString()); loanSetupStep1.loanNumber = reader["loan_number"].ToString(); loanSetupStep1.maturityDate = Convert.ToDateTime(reader["maturity_date"].ToString()); loanSetupStep1.nonRegisteredBranchId = int.Parse(reader["non_reg_branch_id"].ToString()); loanSetupStep1.paymentMethod = reader["payment_method"].ToString(); loanSetupStep1.startDate = Convert.ToDateTime(reader["start_date"].ToString()); loanSetupStep1.RegisteredBranchId = Convert.ToInt32(reader["branch_id"].ToString()); loanSetupStep1.LoanStatus = Convert.ToBoolean(reader["loan_status"]); loanSetupStep1.RegisteredBranchCode = reader["r_branch_code"].ToString(); loanSetupStep1.RegisteredCompanyCode = reader["company_code"].ToString(); if (reader["curtailment_due_date"].ToString() == "EoM") { loanSetupStep1.CurtailmentDueDate = "End of Month"; } else { string dueDate = reader["curtailment_due_date"].ToString(); if (dueDate.Length > 0) { if (dueDate.Length == 1) { if (dueDate.Contains("1")) { loanSetupStep1.CurtailmentDueDate = dueDate + "st of each month"; } else if (dueDate.Contains("2")) { loanSetupStep1.CurtailmentDueDate = dueDate + "nd of each month"; } else if (dueDate.Contains("3")) { loanSetupStep1.CurtailmentDueDate = dueDate + "rd of each month"; } else { loanSetupStep1.CurtailmentDueDate = dueDate + "th of each month"; } } else if (dueDate.Length > 1) { if (!dueDate.ElementAt(dueDate.Length - 2).ToString().Contains("1")) { if (dueDate.ElementAt(dueDate.Length - 1).ToString().Contains("1")) { loanSetupStep1.CurtailmentDueDate = dueDate + "st of each month"; } else if (dueDate.ElementAt(dueDate.Length - 1).ToString().Contains("2")) { loanSetupStep1.CurtailmentDueDate = dueDate + "nd of each month"; } else if (dueDate.ElementAt(dueDate.Length - 1).ToString().Contains("3")) { loanSetupStep1.CurtailmentDueDate = dueDate + "rd of each month"; } else { loanSetupStep1.CurtailmentDueDate = dueDate + "th of each month"; } } else { loanSetupStep1.CurtailmentDueDate = dueDate + "th of each month"; } } } //loanSetupStep1.CurtailmentDueDate = reader["curtailment_due_date"].ToString()+"th of each month"; } //loanSetupStep1.CurtailmentDueDate = reader["curtailment_due_date"].ToString(); } reader.Close(); IList <UnitType> unittypes = new List <UnitType>(); using (SqlCommand cmd2 = new SqlCommand("spGetLoanUnitTypesByLoanId", con)) { cmd2.CommandType = CommandType.StoredProcedure; cmd2.Parameters.Add("@loan_id", SqlDbType.Int).Value = loanSetupStep1.loanId; //con.Open(); SqlDataReader reader2 = cmd2.ExecuteReader(); while (reader2.Read()) { UnitType unitType = new UnitType(); unitType.unitTypeId = int.Parse(reader2["unit_type_id"].ToString()); unitType.unitTypeName = reader2["unit_type_name"].ToString(); unittypes.Add(unitType); } loanSetupStep1.selectedUnitTypes = unittypes; return(loanSetupStep1); } } } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } } }
internal LoanSetupStep1 GetLoanStepOne(int loanId) { LoanSetupStep1 loanSetupStep1 = new LoanSetupStep1(); IList <UnitType> unittypes = new List <UnitType>(); DataHandler dataHandler = new DataHandler(); List <object[]> paramertList = new List <object[]>(); paramertList.Add(new object[] { "@loan_id", loanId }); try { DataSet dataSet = dataHandler.GetDataSet("spGetLoanStepOneByLoanId", paramertList); if (dataSet != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows.Count != 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; loanSetupStep1.advancePercentage = int.Parse(dataRow["advance"].ToString()); //loanSetupStep1.allUnitTypes loanSetupStep1.autoReminderEmail = dataRow["auto_remind_email"].ToString(); loanSetupStep1.autoReminderPeriod = int.Parse(dataRow["auto_remind_period"].ToString()); loanSetupStep1.defaultUnitType = int.Parse(dataRow["default_unit_type"].ToString()); loanSetupStep1.isEditAllowable = Convert.ToBoolean(dataRow["is_edit_allowable"].ToString()); loanSetupStep1.isInterestCalculate = Convert.ToBoolean(dataRow["is_interest_calculate"].ToString()); loanSetupStep1.loanAmount = Convert.ToDecimal(dataRow["loan_amount"].ToString()); loanSetupStep1.loanNumber = dataRow["loan_number"].ToString(); //loanSetupStep1.loanNumberForDisplay = loanSetupStep1.loanNumber; loanSetupStep1.maturityDate = Convert.ToDateTime(dataRow["maturity_date"].ToString()); loanSetupStep1.nonRegisteredBranchId = int.Parse(dataRow["non_reg_branch_id"].ToString()); loanSetupStep1.paymentMethod = dataRow["payment_method"].ToString(); //loanSetupStep1.payOffPeriod = int.Parse(dataRow["pay_off_period"].ToString()); //loanSetupStep1.payOffPeriodType = (Convert.ToChar(dataRow["pay_off_type"].ToString()) == 'd') ? 0 : 1; //loanSetupStep1.selectedUnitTypes loanSetupStep1.startDate = Convert.ToDateTime(dataRow["start_date"].ToString()); loanSetupStep1.loanCode = dataRow["loan_code"].ToString(); } DataSet dataSet2 = dataHandler.GetDataSet("spGetLoanUnitTypesByLoanId", paramertList); if (dataSet2 != null && dataSet2.Tables.Count != 0 && dataSet2.Tables[0].Rows.Count != 0) { foreach (DataRow dataRow2 in dataSet2.Tables[0].Rows) { UnitType unitType = new UnitType(); unitType.unitTypeId = int.Parse(dataRow2["unit_type_id"].ToString()); unitType.unitTypeName = dataRow2["unit_type_name"].ToString(); unittypes.Add(unitType); } loanSetupStep1.selectedUnitTypes = unittypes; } return(loanSetupStep1); } catch (Exception ex) { throw ex; } //using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["AutoDealersConnection"].ConnectionString)) //{ // try // { // using (SqlCommand cmd = new SqlCommand("spGetLoanStepOneByLoanId", con)) // { // cmd.CommandType = CommandType.StoredProcedure; // cmd.Parameters.Add("@loan_id", SqlDbType.Int).Value = loanId; // con.Open(); // SqlDataReader reader = cmd.ExecuteReader(); // LoanSetupStep1 loanSetupStep1 = new LoanSetupStep1(); // while (reader.Read()) // { // loanSetupStep1.advancePercentage = int.Parse(reader["advance"].ToString()); // //loanSetupStep1.allUnitTypes // loanSetupStep1.autoReminderEmail = reader["auto_remind_email"].ToString(); // loanSetupStep1.autoReminderPeriod = int.Parse(reader["auto_remind_period"].ToString()); // loanSetupStep1.defaultUnitType = int.Parse(reader["default_unit_type"].ToString()); // loanSetupStep1.isEditAllowable = Convert.ToBoolean(reader["is_edit_allowable"].ToString()); // loanSetupStep1.isInterestCalculate = Convert.ToBoolean(reader["is_interest_calculate"].ToString()); // loanSetupStep1.loanAmount = Convert.ToDecimal(reader["loan_amount"].ToString()); // loanSetupStep1.loanNumber = reader["loan_number"].ToString(); // loanSetupStep1.loanNumberForDisplay = loanSetupStep1.loanNumber; // loanSetupStep1.maturityDate = Convert.ToDateTime(reader["maturity_date"].ToString()); // loanSetupStep1.nonRegisteredBranchId = int.Parse(reader["non_reg_branch_id"].ToString()); // loanSetupStep1.paymentMethod = reader["payment_method"].ToString(); // loanSetupStep1.payOffPeriod = int.Parse(reader["pay_off_period"].ToString()); // loanSetupStep1.payOffPeriodType = (Convert.ToChar(reader["pay_off_type"].ToString()) == 'd') ? 0 : 1; // //loanSetupStep1.selectedUnitTypes // loanSetupStep1.startDate = Convert.ToDateTime(reader["start_date"].ToString()); // loanSetupStep1.loanCode = reader["loan_code"].ToString(); // } // reader.Close(); // IList<UnitType> unittypes = new List<UnitType>(); // using (SqlCommand cmd2 = new SqlCommand("spGetLoanUnitTypesByLoanId", con)) // { // cmd2.CommandType = CommandType.StoredProcedure; // cmd2.Parameters.Add("@loan_id", SqlDbType.Int).Value = loanId; // //con.Open(); // SqlDataReader reader2 = cmd2.ExecuteReader(); // while (reader2.Read()) // { // UnitType unitType = new UnitType(); // unitType.unitTypeId = int.Parse(reader2["unit_type_id"].ToString()); // unitType.unitTypeName = reader2["unit_type_name"].ToString(); // unittypes.Add(unitType); // } // loanSetupStep1.selectedUnitTypes = unittypes; // return loanSetupStep1; // } // } // } // catch (Exception ex) // { // throw ex; // } // finally // { // con.Close(); // } //} }
internal int insertLoanStepOne(LoanSetupStep1 loanSetupStep1, int loanId) { DataHandler dataHandler = new DataHandler(); List <object[]> paramertList = new List <object[]>(); try { paramertList.Add(new object[] { "@loan_id", loanId }); paramertList.Add(new object[] { "@advance", loanSetupStep1.advancePercentage }); paramertList.Add(new object[] { "@auto_remind_email", loanSetupStep1.autoReminderEmail }); paramertList.Add(new object[] { "@auto_remind_period", loanSetupStep1.autoReminderPeriod }); paramertList.Add(new object[] { "@default_unit_type", loanSetupStep1.defaultUnitType }); paramertList.Add(new object[] { "@is_edit_allowable", loanSetupStep1.isEditAllowable }); paramertList.Add(new object[] { "@is_interest_calculate", loanSetupStep1.isInterestCalculate }); paramertList.Add(new object[] { "@loan_amount", loanSetupStep1.loanAmount }); paramertList.Add(new object[] { "@loan_number", loanSetupStep1.loanNumber }); paramertList.Add(new object[] { "@maturity_date", loanSetupStep1.maturityDate }); paramertList.Add(new object[] { "@non_reg_branch_id", loanSetupStep1.nonRegisteredBranchId }); paramertList.Add(new object[] { "@payment_method", loanSetupStep1.paymentMethod }); //paramertList.Add(new object[] { "@pay_off_period", loanSetupStep1.payOffPeriod }); //paramertList.Add(new object[] { "@pay_off_type", ((loanSetupStep1.payOffPeriodType == 0) ? 'd' : 'm') }); paramertList.Add(new object[] { "@loan_code", (new BranchAccess()).getBranchByBranchId(loanSetupStep1.RegisteredBranchId).BranchCode + "-" + loanSetupStep1.loanNumber }); paramertList.Add(new object[] { "@start_date", loanSetupStep1.startDate }); paramertList.Add(new object[] { "@created_date", DateTime.Now }); paramertList.Add(new object[] { "@loan_status", false }); paramertList.Add(new object[] { "@is_delete", false }); //DataSet dataSet = dataHandler.GetDataSet("spInsertLoanStepOne", paramertList); //if (dataSet != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows.Count != 0) //{ // loanId =int.Parse(dataSet.Tables[0].Rows[0]["return"].ToString()); //} loanId = dataHandler.ExecuteSQLWithReturnVal("spInsertLoanStepOne", paramertList); if (loanId == 0) { return(loanId); } else { foreach (UnitType UnitType in loanSetupStep1.allUnitTypes) { if (UnitType.isSelected == true) { List <object[]> paramertList1 = new List <object[]>(); paramertList1.Add(new object[] { "@loan_id", loanId }); paramertList1.Add(new object[] { "@unit_type_id", UnitType.unitTypeId }); dataHandler.GetDataSet("spInsertLoanUniType", paramertList1); } } return(loanId); } } catch (Exception ex) { throw ex; } }
/* * * Frontend page: Fee Page * Title: Load the Fee Page * Designed: Nadeeka * User story: * Developed: Nadeeka * Date created: 4/20/2016 * */ public ActionResult PayFees() { try { lCode = Session["loanCode"].ToString(); // take the loan code on session } // if there is no loan on Session -- redirect to login catch (Exception) { return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." })); } LoanSetupStep1 loanDetails = new LoanSetupStep1(); loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(Session["loanCode"].ToString()); // take the loan details of loan code // pass loan details to the view ViewBag.loanDetails = loanDetails; Loan loanSelected = new Loan(); // take the loan which was selected from the dashboard and pass it to the view if (Session["loanDashboard"] != null) { loanSelected = (Loan)Session["loanDashboard"]; } else if (Session["oneLoanDashboard"] != null) { loanSelected = (Loan)Session["oneLoanDashboard"]; } else { // if there is no loan selected from dashboard -- wrong access return(RedirectToAction("Login", "UserLogin")); } ViewBag.loanSelected = loanSelected; // if user is a normal user, checking the user permission if (userData.RoleId == 3) { if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "") { return(RedirectToAction("UserDetails", "UserManagement")); } else { var checkPermission = false; string rgts = ""; rgts = (string)Session["CurrentLoanRights"]; string[] rgtList = null; if (rgts != "") { rgtList = rgts.Split(','); } if (rgtList != null) { foreach (var x in rgtList) { if (x == "U07") { checkPermission = true; } } if (checkPermission == false) { return(RedirectToAction("UserDetails", "UserManagement")); } } else { return(RedirectToAction("UserDetails", "UserManagement")); } } } // if user is a dealer user -- he is not allowed to fee page else if (userData.RoleId == 4) { return(RedirectToAction("UserDetails", "UserManagement")); } // take the due dates of advance fee, monthly loan fee and lot inspection fee string advDuedate; string monDueDate; string lotDuedate; bool returnValue = (new FeeAccess()).GetFeesDueDates(loanDetails.loanId, out advDuedate, out monDueDate, out lotDuedate); // pass due dates to view ViewBag.advDuedate = advDuedate; ViewBag.monDueDate = monDueDate; ViewBag.lotDuedate = lotDuedate; // return fee page return(View()); }
/// <summary> /// Frontend Page:Bottom Link Bar of each page in floor plan management section /// Title: return view according to user rights and loan setup details /// Designed: Irfan MAM /// User Story: /// Developed: Piyumi Perera /// Date created: /// </summary> /// <returns></returns> public ActionResult GetLinkBar() { //assign logged user id to int variable int userId = userData.UserId; string loanCode = ""; UserRightsAccess access = new UserRightsAccess(); //retrive all rights List <Right> rights = new List <Right>(); //assign logged user role to int variable int userRole = userData.RoleId; //check Session["loanCode"] is not null and not empty if ((Session["loanCode"] != null) && (!string.IsNullOrEmpty(Session["loanCode"].ToString()))) { //convert session to string variable loanCode = Session["loanCode"].ToString(); } //check user role is user if (userRole == 3) { //retrieve rigts given for the loan rights = access.GetUserRightsByLoanCode(loanCode, userId); } //assign user role to viewbag variable ViewBag.Role = userRole; //check Session["addUnitloan"] is null if (Session["addUnitloan"] == null) { //return to login page return(RedirectToAction("UserLogin", "Login", new { lbl = "Failed find loan" })); } //convert session to loan object LoanSetupStep1 loan = (LoanSetupStep1)Session["addUnitloan"]; //check Session["IsTitleTrack"] is not null if (Session["IsTitleTrack"] != null) { //check session value if (int.Parse(Session["IsTitleTrack"].ToString()) == 1) { //if 1 - title need to be tracked ViewBag.ttlAccess = 1; } else { //else title no need to be tracked ViewBag.ttlAccess = 0; } } else { //else title no need to be tracked ViewBag.ttlAccess = 0; } //check Session["oneLoanDashboard"] which contains loan data if logged user has one loan is not null and not empty if ((Session["oneLoanDashboard"] != null) && (!string.IsNullOrEmpty(Session["oneLoanDashboard"].ToString()))) { Loan loanObj = new Loan(); //convert session to loan object loanObj = (Loan)Session["oneLoanDashboard"]; //check if loan has at least one fee if ((loanObj.LotInspectionFee == 1) || (loanObj.MonthlyLoanFee == 1) || (loanObj.AdvanceFee == 1)) { //assign value 1 for ViewBag.FeeLB ViewBag.FeeLB = 1; } else { //assign value 0 for ViewBag.FeeLB ViewBag.FeeLB = 0; } } //check Session["loanDashboard"] which contains loan data if logged user select in popup is not null and not empty else if ((Session["loanDashboard"] != null) && (!string.IsNullOrEmpty(Session["loanDashboard"].ToString()))) { Loan loanObj = new Loan(); //convert session to loan object loanObj = (Loan)Session["loanDashboard"]; //check if loan has at least one fee if ((loanObj.LotInspectionFee == 1) || (loanObj.MonthlyLoanFee == 1) || (loanObj.AdvanceFee == 1)) { //assign value 1 for ViewBag.FeeLB ViewBag.FeeLB = 1; } else { //assign value 0 for ViewBag.FeeLB ViewBag.FeeLB = 0; } } //check Session["loanDashboard"] and check Session["oneLoanDashboard"] is null else if ((Session["oneLoanDashboard"] == null) && (Session["loanDashboard"] == null)) { //return to login page return(RedirectToAction("UserLogin", "Login")); } //return right list to partial view return(PartialView(rights)); }
/* * * Frontend page : Add Unit * Title : Add or Advance Units * Designed : Kasun Samarawickrama * User story : * Developed : Kasun Samarawickrama * Date created : 02/24/2016 * */ public ActionResult AddUnit() { // Handle Record successfully update or Error message int Flag = 0; if (TempData["Msg"] != null) { Flag = int.Parse(TempData["Msg"].ToString()); if (Flag == 1) { ViewBag.Msg = "Success"; } else if (Flag == 3) { ViewBag.Msg = "Requested"; } else if (Flag == 2) { ViewBag.Msg = "Error"; } } int userId = userData.UserId; ViewBag.Role = userData.RoleId;; //Check loan is null or not if (Session["loanCode"] == null || Session["loanCode"].ToString() == "") { return(RedirectToAction("UserLogin", "Login", new { lbl = "Failed find loan" })); } // for role id3 - user section if (userData.RoleId == 3) { // check user has rights to access this loan - if not redirect to dashboard if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "") { return(RedirectToAction("UserDetails", "UserManagement")); } else { var checkPermission = false; var checkAdvance = false; // check user permission to the site string rgts = ""; rgts = (string)Session["CurrentLoanRights"]; string[] rgtList = null; //spit the permission string if (rgts != "") { rgtList = rgts.Split(','); } if (rgtList != null) { foreach (var x in rgtList) { //check user have rights to add unit page if (x == "U04") { checkPermission = true; } // check user have right to advance units in this page if (x == "U01") { checkAdvance = true; } } if (checkAdvance == true) { ViewBag.advanceAllow = true; } else { ViewBag.advanceAllow = false; } if (checkPermission == false) { return(RedirectToAction("UserDetails", "UserManagement")); } } else { return(RedirectToAction("UserDetails", "UserManagement")); } } } string loanCode = Session["loanCode"].ToString(); // retrive loan details LoanSetupStep1 loan = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); int loanId = loan.loanId; Session["addUnitloan"] = loan; ViewBag.loanDetails = loan; //set default unit type for add unit page if (loan.selectedUnitTypes.Count == 1) { ViewBag.UnitTypeId = loan.selectedUnitTypes[0].unitTypeName; } Models.Unit unit = new Models.Unit(); unit.AdvancePt = loan.advancePercentage; unit.LoanId = loanId; unit.LoanAmount = loan.loanAmount; unit.AdvanceDate = DateTime.Now; unit.StartDate = loan.startDate; unit.EndDate = loan.maturityDate; //get company type //1 - Lender //2 - Dealer BranchAccess ba = new BranchAccess(); int companyType = ba.getCompanyTypeByUserId(userId); ViewBag.CompabyType = companyType; ViewBag.RoleId = userData.RoleId; //Check title TitleAccess ta = new TitleAccess(); Title title = ta.getTitleDetails(loan.loanId); // check title track allow or not if (title != null) { bool isTitleTrack = title.IsTitleTrack; if (isTitleTrack) { ViewBag.IsTitleTrack = "Yes"; } string upload = title.TitleAcceptMethod; if (!string.IsNullOrEmpty(upload) && upload == "Scanned Title Adequate") { ViewBag.Upload = "Yes"; } } // loan Details for (loan Detail box) in the page UnitAccess ua = new UnitAccess(); LoanPaymentDetails loanPaymentDetails = ua.GetLoanPaymentDetailsByLoanId(loanId); unit.Balance = loanPaymentDetails.BalanceAmount; // check balane field is editable or not for this loan ViewBag.Editable = loan.isEditAllowable ? "Yes" : "No"; //set user role to restrict add & advance unit if this user is dealer user(role id = 4) ViewBag.RoleId = userData.RoleId; return(PartialView(unit)); }
/* * * Frontend page : Delete units * Title : Get all active and pending units * Designed : Kanishka Mahanama * User story : * Developed : Kanishka Mahanama * Date created : * */ public ActionResult Delete() { string loanCode; //get loan code, if it is null return to the login try { loanCode = Session["loanCode"].ToString(); } catch (Exception) { return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." })); } //check user role, if it is user then check he has right to delete unit page if (_userData.RoleId == 3) { if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "") { return(RedirectToAction("UserDetails", "UserManagement")); } else { var checkPermission = false; string rgts = ""; rgts = (string)Session["CurrentLoanRights"]; string[] rgtList = null; if (rgts != "") { rgtList = rgts.Split(','); } if (rgtList != null) { foreach (var x in rgtList) { if (x == "U08") { checkPermission = true; } } if (checkPermission == false) { return(RedirectToAction("UserDetails", "UserManagement")); } } else { return(RedirectToAction("UserDetails", "UserManagement")); } } } else if (_userData.RoleId == 4) { return(RedirectToAction("UserDetails", "UserManagement")); } //get loan details int loanId = _userData.LoanId; LoanSetupStep1 loan = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); UnitDeleteViewModel unitDeleteViewModel = new UnitDeleteViewModel(); //get all units UnitAccess ua = new UnitAccess(); unitDeleteViewModel.DeleteUnits = ua.GetAllUnitsByLoanId(loan.loanId); Session["UnitDeleteList"] = unitDeleteViewModel.DeleteUnits; Session["deleteUnitloanId"] = loan.loanId; ViewBag.DeleteList = unitDeleteViewModel.DeleteUnits; return(View(unitDeleteViewModel)); }
/* * * Frontend page: Curtailment Page * Title: Load curtailment page * Designed: Nadeeka * User story: * Developed: Nadeeka * Date created: 3/21/2016 * */ public ActionResult PayCurtailments() { // if user access via url -- wrong access if (Session["loanCode"] == null || Session["loanCode"].ToString() == "") { return(RedirectToAction("UserLogin", "Login", new { lbl = "Failed find loan" })); } lCode = Session["loanCode"].ToString(); // take the loan code // if user is a normal user, check his user rights if (userData.RoleId == 3) { if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "") { return(RedirectToAction("UserDetails", "UserManagement")); } else { var checkPermission = false; string rgts = ""; rgts = (string)Session["CurrentLoanRights"]; string[] rgtList = null; if (rgts != "") { rgtList = rgts.Split(','); } if (rgtList != null) { foreach (var x in rgtList) { if (x == "U05") { checkPermission = true; } } if (checkPermission == false) { return(RedirectToAction("UserDetails", "UserManagement")); } } else { return(RedirectToAction("UserDetails", "UserManagement")); } } } // if user is a dealer user -- he is not allowed else if (userData.RoleId == 4) { return(RedirectToAction("UserDetails", "UserManagement")); } LoanSetupStep1 loanDetails = new LoanSetupStep1(); loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(Session["loanCode"].ToString()); // take the loan details Session["curtLaonId"] = loanDetails.loanId; // save the loan id on session ViewBag.curtTotal = (new CurtailmentAccess()).GetCurtailmentsTotal(loanDetails.loanId); // pass the total amount of curtailment to the view // pass the loan details to the view ViewBag.loanDetails = loanDetails; ViewBag.LoanId = loanDetails.loanId; // return pay curtailment page return(View()); }
/// <summary> /// Frontend page: Advance Unit /// Title: Get loan details and not advanced unit details from database and return to view /// Designed: Nadeeka /// User story: /// Developed: Nadeeka /// Date created: 02/24/2016 /// </summary> /// <param name="model"></param> /// <returns>Return partial view</returns> public ActionResult Advance() { int flag = -1; //assign logged user id to variable int userId = userData.UserId; string loanCode; try { //convert session to string variable loanCode = Session["loanCode"].ToString(); } catch (Exception) { //if exception occured return to login page return(RedirectToAction("UserLogin", "Login")); } BranchAccess branch = new BranchAccess(); //retrieve company type for given user id int companyType = branch.getCompanyTypeByUserId(userId); //check company type 1-Lender if (companyType == 1) { ViewBag.isLender = true; } //company type 2 - Dealer else { ViewBag.isLender = false; } ViewBag.unitClickId = ""; LoanSetupStep1 loanDetails = new LoanSetupStep1(); //retrieve loan delails for given loan code loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); //check logged user role is user if (userData.RoleId == 3) { //check Session["CurrentLoanRights"] is null or empty if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "") { return(RedirectToAction("UserDetails", "UserManagement")); } else { var checkPermission = false; string rgts = ""; //convert Session["CurrentLoanRights"] to string variable rgts = (string)Session["CurrentLoanRights"]; string[] rgtList = null; //check right string is not empty if (rgts != "") { //split string rgtList = rgts.Split(','); } //check right list is not null if (rgtList != null) { foreach (var x in rgtList) { //check relevant right for Advance Unit page contains in the user right list if (x == "U01") { checkPermission = true; } } //check permission value is false if (checkPermission == false) { //return to dashboard return(RedirectToAction("UserDetails", "UserManagement")); } } else { //return to dashboard return(RedirectToAction("UserDetails", "UserManagement")); } } } //check logged user is dealer user else if (userData.RoleId == 4) { //return to dashboard return(RedirectToAction("UserDetails", "UserManagement")); } ViewBag.loanDetails = loanDetails; Models.Unit unit = new Models.Unit(); //get units which need to advance for given loan id AdvanceUnit advanceUnit = this.GetAdvanceUnitList(loanDetails.loanId); //assign loan id to session object Session["advUnitloanId"] = loanDetails.loanId; //assign not advanced unit list to session object Session["notAdvancedList"] = advanceUnit.NotAdvanced; ViewBag.advanceList = advanceUnit.NotAdvanced; //check update result of Advance Unit page if ((TempData["updateReslt"] != null) && (TempData["updateReslt"].ToString() != "")) { //convert result to integer flag = int.Parse(TempData["updateReslt"].ToString()); } //check result value is 1 if (flag == 1) { //flag 1 - success ViewBag.Msg = "Success"; } else if (flag == 0) { //flag 0 - error ViewBag.Msg = "Error"; } else if (flag == 2) { //flag 2 - Advance amount error ViewBag.Msg = "Advance amount error"; } else if (flag == 3) { //flag 3 - Advance error ViewBag.Msg = "Advance Error"; } //return advance unit list to view return(View(advanceUnit)); }
/// <summary> /// Frontend page: Advance Unit /// Title: Advance more than one unit /// Designed: Nadeeka /// User story: /// Developed: Nadeeka /// Date created: 02/25/2016 /// CreatedBy : Nadeeka /// </summary> /// <param name="model"></param> /// <returns>Return partial view</returns> public int UpdateAdvanceAll(ListViewModel list) { string loanCode; try { //convert session to string variable loanCode = Session["loanCode"].ToString(); } catch (Exception) { throw; } //get loan details by loan code LoanSetupStep1 loanSetupStep1 = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); ViewBag.ErrorMsg = ""; //check Session["notAdvancedList"] is not null if (Session["notAdvancedList"] != null) { List <Models.Unit> lstUnit = (List <Models.Unit>)Session["notAdvancedList"]; foreach (Models.Unit modifiedUnit in list.ItemList) { //check advance amount can not be edited and given advance amount in loanset up and advance amount of selected unit is equal if (!loanSetupStep1.isEditAllowable && lstUnit.Find(a => a.UnitId == modifiedUnit.UnitId).AdvanceAmount != modifiedUnit.AdvanceAmount) { TempData["updateReslt"] = 3; return(0); } } } UnitAccess unitAccess = new UnitAccess(); //get result of advance item list int reslt = unitAccess.AdvanceItemList(list.ItemList, loanSetupStep1.loanId, userData.UserId, list.ItemList[0].AdvanceDate); TempData["updateReslt"] = reslt; // after success save** if (reslt == 1) { string[] arrList = new string[list.ItemList.Count]; int i = 0; foreach (var x in list.ItemList) { if (!string.IsNullOrEmpty(x.UnitId)) { arrList[i] = "Advanced Unit: " + x.IdentificationNumber + " ,Advance amount:" + x.AdvanceAmount + " ,Advance date: " + x.AdvanceDate; i++; } } string units = string.Join(",", arrList); //insert log data Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanSetupStep1.loanId, "Advance Unit", units, DateTime.Now); int islog = (new LogAccess()).InsertLog(log); //if mention advance fee, then insert in to fee table - asanka if ((Session["loanDashboard"] != null) || (Session["oneLoanDashboard"] != null)) { Loan loanObj = new Loan(); if (Session["loanDashboard"] != null) { loanObj = (Loan)Session["loanDashboard"]; } else { loanObj = (Loan)Session["oneLoanDashboard"]; } //loanObj = (Loan)Session["loanDashboard"]; if (loanObj.AdvanceFee == 1) { //check advance amount and other details foreach (BankLoanSystem.Models.Unit unitObj in list.ItemList) { unitAccess.insertFreeDetailsForAdvance(unitObj, loanSetupStep1.loanId); } } } // saving for reporting purpose if (Session["AdvItems"] == null) { Session["AdvItems"] = list.ItemList; } else { List <Models.Unit> unitlist = new List <Models.Unit>(); unitlist = (List <Models.Unit>)Session["AdvItems"]; unitlist.AddRange(list.ItemList); Session["AdvItems"] = unitlist; } } return(reslt); }
/// <summary> /// Frontend page: Advance Unit /// Title: Advance one unit /// Designed: Nadeeka /// User story: /// Developed: Nadeeka /// Date created: 02/24/2016 /// </summary> /// <param name="model"></param> /// <returns>Return partial view</returns> public int UpdateAdvance(BankLoanSystem.Models.Unit unit) { string loanCode; try { //convert session to string variable loanCode = Session["loanCode"].ToString(); } catch (Exception) { throw; } //get loan details by loan code LoanSetupStep1 loanSetupStep1 = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); ViewBag.ErrorMsg = ""; UnitAccess unitAccess = new UnitAccess(); //check Session["notAdvancedList"] is not null if (Session["notAdvancedList"] != null) { //convert Session["notAdvancedList"] to list object List <Models.Unit> lstUnit = (List <Models.Unit>)Session["notAdvancedList"]; //check advance amount can not be edited and given advance amount in loanset up and advance amount of selected unit is equal if (!loanSetupStep1.isEditAllowable && lstUnit.Find(a => a.UnitId == unit.UnitId).AdvanceAmount != unit.AdvanceAmount) { TempData["updateReslt"] = 3; return(3); } } //get result of advance one item int reslt = unitAccess.AdvanceItem(unit, loanSetupStep1.loanId, userData.UserId, unit.AdvanceDate); TempData["updateReslt"] = reslt; // after success save** //check result of advance if (reslt == 1) { //if mention advance fee, then insert in to fee table - asanka if ((Session["loanDashboard"] != null) || (Session["oneLoanDashboard"] != null)) { Loan loanObj = new Loan(); if (Session["loanDashboard"] != null) { loanObj = (Loan)Session["loanDashboard"]; } else if (Session["oneLoanDashboard"] != null) { loanObj = (Loan)Session["oneLoanDashboard"]; } if (loanObj.AdvanceFee == 1) { //check advance amount and other details unitAccess.insertFreeDetailsForAdvance(unit, loanSetupStep1.loanId); } } //insert to log Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanSetupStep1.loanId, "Advance Unit", "Advanced Unit:" + unit.IdentificationNumber + (unit.Cost * loanSetupStep1.advancePercentage / 100 != unit.AdvanceAmount ? ",Advance amount edited to: " + unit.AdvanceAmount : ",Advance amount: " + unit.AdvanceAmount) + " ,Advance date:" + unit.AdvanceDate, DateTime.Now); int islog = (new LogAccess()).InsertLog(log); // saving for reporting purpose if (Session["AdvItems"] == null) { List <Models.Unit> unitlist = new List <Models.Unit>(); unitlist.Add(unit); Session["AdvItems"] = unitlist; } else { List <Models.Unit> unitlist = new List <Models.Unit>(); unitlist = (List <Models.Unit>)Session["AdvItems"]; unitlist.Add(unit); Session["AdvItems"] = unitlist; } } return(reslt); }
public ActionResult loadGrid() { string loanCode; try { loanCode = Session["loanCode"].ToString(); } catch (Exception) { //filterContext.Controller.TempData.Add("UserLogin", "Login"); return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." })); } LoanSetupStep1 loanDetails = new LoanSetupStep1(); loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); BranchAccess ba = new BranchAccess(); ViewBag.ComType = userData.CompanyType; ViewBag.loanId = loanDetails.loanId; ViewBag.loanDetails = loanDetails; UnitPayOffViewModel unitPayOffViewModel = new UnitPayOffViewModel(); CurtailmentAccess payoff = new CurtailmentAccess(); unitPayOffViewModel.UnitPayOffList = new List <UnitPayOffModel>(); unitPayOffViewModel.PayDate = DateTime.Now; unitPayOffViewModel.UnitPayOffList = payoff.GetUnitPayOffList(loanDetails.loanId); decimal advanceFee = 0; advanceFee = payoff.AdvanceForPayOffUnits(loanDetails.loanId); //int advanceFeeAtPayoff = payoff.CheckAdvanceFeeAtPayOff(loanDetails.loanId); //if (advanceFeeAtPayoff == 1) { // foreach (var unit in unitPayOffViewModel.UnitPayOffList) { // unit.IsAdvancePaid = false; // } //} ViewBag.AdvanceFee = advanceFee; var unitPayOffList = unitPayOffViewModel.UnitPayOffList; Session["payoffList"] = unitPayOffList; ViewBag.payOffList = unitPayOffList; TitleAccess ta = new TitleAccess(); Title title = ta.getTitleDetails(loanDetails.loanId); Session["PayOffUnitloanId"] = loanDetails.loanId; if (title != null) { bool isTitleTrack = title.IsTitleTrack; if (isTitleTrack) { ViewBag.IsTitleTrack = "Yes"; } } return(PartialView(unitPayOffViewModel)); }