public UnitVm(Models.Unit _unit) { Idunit = _unit.Idunit; Namabarang = _unit.Namabarang; Harga = _unit.Harga; Stok = _unit.Stok; }
public async Task <Models.Unit> UpdateUnit(Models.Unit unit, string token = "") { await CommodityDatabase.Instance .SaveUnitAsync(unit); return(unit); }
public async Task <Models.Unit> AddUnit(Models.Unit unit, string token = "") { var id = await CommodityDatabase.Instance .SaveUnitAsync(unit); unit.Id = id; return(unit); }
/* * 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 Models.Unit ParseToUnit() { Models.Unit unit = new Models.Unit { Id = Guid.NewGuid().ToString(), Code = this.Code, Name = this.Name, OrganizationId = this.OrganizationId }; return(unit); }
public ActionResult <IEnumerable <object> > Get(string id) { TestAPI.Utils ut = new TestAPI.Utils(); string response = ""; response = ut.getUnit(id); Models.Unit unit = new Models.Unit(); unit = Newtonsoft.Json.JsonConvert.DeserializeObject <TestAPI.Models.Unit>(response); return(new object[] { unit }); }
public async Task <Models.Unit> UpdateUnit(Models.Unit unit, string token = "") { var builder = new UriBuilder(GlobalSettings.Instance.UnitEndpoint) { Path = $"{ApiUrlBase}{unit.Id}" }; var uri = builder.ToString(); var result = await _requestProvider.PutAsync(uri, unit, token); return(result); }
private static void RunPrometheusExporter() { Models.MySettingsConfig mySettingsConfig = new Models.MySettingsConfig(); mySettingsConfig.SQLConn = "Server=10.40.11.83;Database=CAD;User Id=phmelo;Password=moHaa231"; mySettingsConfig.RedisConn = "10.40.11.74:6379,10.40.11.75:6379,10.40.11.76:6379,password=redis"; mySettingsConfig.RedisTest = "10.40.11.43:6379,password=redis"; mySettingsConfig.RedisBus = "10.40.11.43:6389,password=redis"; mySettingsConfig.port = 1237; int BusResult = Data.Redis.GetBusLen(mySettingsConfig.RedisBus); var AgencyEventSQLResult = Data.SqlDB.GetEventData(mySettingsConfig.SQLConn); var AgencyEventRedisResult = Data.Redis.GetEventData(mySettingsConfig.RedisConn); int MinutesWithoutCallId = Data.SqlDB.GetEventCreatedWithoutCallerIdReceived(mySettingsConfig.SQLConn); var UnitSQLResult = Data.SqlDB.GetUnitData(mySettingsConfig.SQLConn); var UnitRedisResult = Data.Redis.GetUnitData("cad-units", mySettingsConfig.RedisConn); double SqlTotEvt = 0; double SqlTotUnit = 0; double RdsTotEvt = AgencyEventRedisResult.Count; double RdsTotUnit = UnitRedisResult.Count; double AgencyEventStatusDiffTot = 0; double AgencyEventDgroupDiffTot = 0; double UnitStatusDiffTot = 0; double UnitDgroupDiffTot = 0; double AgencyEventQtdDiffTot = 0; double UnitQtdDiffTot = 0; double AnyDiffTot = 0; foreach (var ev in AgencyEventSQLResult) { Models.AgencyEvent ValueResult = null; if (AgencyEventRedisResult.TryGetValue(ev.AgencyEventId, out ValueResult)) { if (ev.DispatchGroup != ValueResult.DispatchGroup) { AgencyEventDgroupDiffTot++; } if (ev.EventStatusCode != ValueResult.EventStatusCode) { AgencyEventStatusDiffTot++; } } SqlTotEvt++; } foreach (var u in UnitSQLResult) { Models.Unit ValueResult = null; if (UnitRedisResult.TryGetValue(u.UnitId, out ValueResult)) { if (u.DispatchGroup != ValueResult.DispatchGroup) { UnitDgroupDiffTot++; } if (u.CurrentStatus != ValueResult.CurrentStatus) { UnitStatusDiffTot++; } } SqlTotUnit++; } AgencyEventQtdDiffTot = Math.Abs(SqlTotEvt - RdsTotEvt); UnitQtdDiffTot = Math.Abs(SqlTotUnit - RdsTotUnit); AnyDiffTot = AgencyEventQtdDiffTot + AgencyEventDgroupDiffTot; AgencyEvent.WithLabels("RedisTotal").Set(RdsTotEvt); AgencyEvent.WithLabels("SQLTotal").Set(SqlTotEvt); AgencyEvent.WithLabels("DgroupDiff").Set(AgencyEventDgroupDiffTot); AgencyEvent.WithLabels("StatusDiff").Set(AgencyEventStatusDiffTot); AgencyEvent.WithLabels("EventDiff").Set(AgencyEventQtdDiffTot); AgencyEvent.WithLabels("AnyDiff").Set(AnyDiffTot); AgencyEvent.WithLabels("MinutesWithoutCallId").Set(MinutesWithoutCallId); Unit.WithLabels("RedisTotal").Set(RdsTotUnit); Unit.WithLabels("SQLTotal").Set(SqlTotUnit); Unit.WithLabels("DgroupDiff").Set(UnitDgroupDiffTot); Unit.WithLabels("StatusDiff").Set(UnitStatusDiffTot); Unit.WithLabels("UnitDiff").Set(UnitQtdDiffTot); var SessionRedisResult = Data.Redis.GetSessiontData(mySettingsConfig.RedisConn); Sessions.WithLabels("Online").Set(SessionRedisResult.Count); var test = new SortedSet <string>(); int totDuplicatedSessions = 0; foreach (var session in SessionRedisResult) { if (!string.IsNullOrEmpty(session.Value.positionId)) { Console.WriteLine("Key:" + session.Key + "; Empid:" + session.Value.employeeId + "; PositionID:" + session.Value.positionId + ";"); Console.WriteLine(session.Value.ToString()); } if (session.Value.SessionCount != 0) { totDuplicatedSessions++; //Console.WriteLine(session.Value.employeeId + ": " + session.Value.positionIds); } } Console.WriteLine(test); Sessions.WithLabels("Duplicated").Set(totDuplicatedSessions); }
/// <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: 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); }
/* * * 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)); }
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)); }
/* 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); }