public ActionResult Step5(string lbls) { int userId = userData.UserId; BranchAccess ba = new BranchAccess(); //get company type int compType = ba.getCompanyTypeByUserId(userId); //if lender company if (compType == 1) { ViewBag.ThisCompanyType = "Dealer"; } //if dealer company else if (compType == 2) { ViewBag.ThisCompanyType = "Lender"; } else { ViewBag.compType = ""; } StepAccess cs = new StepAccess(); //convert session to integer int stepNo = Convert.ToInt32(Session["companyStep"]); //check step is less than 0 if (stepNo < 0) { stepNo = Convert.ToInt32(Session["companyStep"]); } //check step is less than 5 and return to login page if (stepNo < 5) return RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." }); //check result of insert or update if (lbls != null && (lbls.Equals("Dealer branch is successfully created") || lbls.Equals("Lender branch is successfully created"))) { ViewBag.SuccessMsg = lbls; //check ajax request if (HttpContext.Request.IsAjaxRequest()) { ViewBag.AjaxRequest = 1; return PartialView(); } else { return View(); } } CompanyBranchModel userNonRegCompany = new CompanyBranchModel(); //check TempData["NonRegCompany"] (partner company ) is not null and empty if ((TempData["NonRegCompany"] != null) && (TempData["NonRegCompany"].ToString() != "")) { //convert to model object userNonRegCompany = (CompanyBranchModel)TempData["NonRegCompany"]; userNonRegCompany.MainBranch = new Branch(); //check extension is null if (userNonRegCompany.Company.Extension == null) userNonRegCompany.Company.Extension = ""; } ViewBag.CurrUserRoleType = userData.RoleId; //Get states to list CompanyAccess ca = new CompanyAccess(); List<State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); // get all branches List<Branch> branchesLists = (new BranchAccess()).getBranches(userData.Company_Id); ViewBag.RegBranchId = new SelectList(branchesLists, "BranchId", "BranchName"); //Get all non reg companies List<Company> nonRegCompanyList = ca.GetCompanyByCreayedCompany(userData.Company_Id); ViewBag.NonRegCompanyId = new SelectList(nonRegCompanyList, "CompanyId", "CompanyName", 1); NonRegCompanyBranchModel nonRegCompanyBranch = new NonRegCompanyBranchModel(); nonRegCompanyBranch.CompanyBranch = new CompanyBranchModel(); nonRegCompanyBranch.CompanyBranch.Company = new Company(); nonRegCompanyBranch.NonRegCompany= new Company(); //Get all non registered branches by company id List<NonRegBranch> nonRegBranches = ba.getNonRegBranches(userData.Company_Id); nonRegCompanyBranch.NonRegBranches = nonRegBranches; if ((TempData["NonRegCompany"] != null) && (TempData["NonRegCompany"].ToString() != "")) { nonRegCompanyBranch.CompanyBranch.Company = userNonRegCompany.Company; } else { nonRegCompanyBranch.CompanyBranch.Company = nonRegCompanyList[0]; } //check partner company list is not null if (nonRegCompanyList != null) { //check if one partner company and assign that company id if (nonRegCompanyList.Count() == 1) { nonRegCompanyBranch.NonRegCompany.CompanyId = nonRegCompanyList[0].CompanyId; } } //check user is not admin if (userData.RoleId != 2) { //check ajax request if (HttpContext.Request.IsAjaxRequest()) { ViewBag.AjaxRequest = 1; return PartialView(nonRegCompanyBranch); } else { return View(nonRegCompanyBranch); } } //Select non registered branch for admin's branch if (nonRegBranches != null) { var adminBonRegBranches = new List<NonRegBranch>(); adminBonRegBranches.AddRange(nonRegBranches.Where(t => userData.BranchId == t.BranchId)); nonRegCompanyBranch.NonRegBranches = adminBonRegBranches; } //check ajax request if (HttpContext.Request.IsAjaxRequest()) { ViewBag.AjaxRequest = 1; return PartialView(nonRegCompanyBranch); } else { return View(nonRegCompanyBranch); } }
public ActionResult EditPartnerBranchAtDashboard(string lbls) { if (userData.RoleId != 1 && userData.RoleId != 2) { return RedirectToAction("UserDetails", "UserManagement"); } if (lbls != null && (lbls.Equals("Dealer branch is successfully updated") || lbls.Equals("Lender branch is successfully updated"))) { ViewBag.SuccessMsg = lbls; } else if (lbls != null && (lbls.Equals("Failed to update"))) { ViewBag.ErrorMsg = lbls; } BranchAccess ba = new BranchAccess(); _compType = ba.getCompanyTypeByUserId(userData.UserId); //int compType = userData.CompanyType; if (_compType == 1) { ViewBag.ThisCompanyType = "Dealer"; } else if (_compType == 2) { ViewBag.ThisCompanyType = "Lender"; } else { ViewBag.compType = ""; } // get all branches List<Branch> branchesLists = (new BranchAccess()).getBranches(userData.Company_Id); //Get all non registered branches by company id EditPartnerBranceModel nonRegCompanyBranch = new EditPartnerBranceModel(); List<NonRegBranch> nonRegBranches = ba.getNonRegBranches(userData.Company_Id); //filter admin's branch if (userData.RoleId == 2) { branchesLists = branchesLists.Where(x => x.BranchId == userData.BranchId).ToList(); nonRegBranches = nonRegBranches.Where(x => x.BranchId == userData.BranchId).ToList(); } nonRegCompanyBranch.NonRegBranches = nonRegBranches; ViewBag.RegBranchId = new SelectList(branchesLists, "BranchId", "BranchName"); ViewBag.Count = nonRegBranches.Count; //Get all non reg companies CompanyAccess ca = new CompanyAccess(); List<Company> nonRegCompanyList = ca.GetCompanyByCreayedCompany(userData.Company_Id); ViewBag.NonRegCompanyId = new SelectList(nonRegCompanyList, "CompanyId", "CompanyName", 1); //Get states to list List<State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); return View(nonRegCompanyBranch); }
public ActionResult Step4() { StepAccess sa = new StepAccess(); //convert session to integer int stepNo = Convert.ToInt32(Session["companyStep"]); //check company step is 3 if (stepNo == 3) { //update company set up step to 4 if (sa.UpdateCompanySetupStep(userData.Company_Id, userData.BranchId, 4)) { //check Session["companyStep"] value is less than 4 if (Convert.ToInt32(Session["companyStep"].ToString()) < 4) { //update Session["companyStep"] to 4 Session["companyStep"] = 4; } } stepNo = Convert.ToInt32(Session["companyStep"]); } //check company step is equal or greater than 3 if (stepNo >= 3) { BranchAccess ba = new BranchAccess(); //get company type int comType = ba.getCompanyTypeByUserId(userData.UserId); //set partner company type //company type 1-lender,company type 2 - dealer ViewBag.ThisCompanyType = (comType == 1) ? "Dealer" : "Lender"; //Get states to list CompanyAccess ca = new CompanyAccess(); List<State> stateList = ca.GetAllStates(); ViewBag.StateId = new SelectList(stateList, "StateId", "StateName"); //get partner companies List<Company> nonRegCompanies = ca.GetCompanyByCreayedCompany(userData.Company_Id);//regCompany.CompanyId asanka CompanyViewModel companyViewModel = new CompanyViewModel(); companyViewModel.Companies = nonRegCompanies; //check ajax request if (HttpContext.Request.IsAjaxRequest()) { ViewBag.AjaxRequest = 1; return PartialView(companyViewModel); } else { return View(companyViewModel); } } //is company step is less than 3 return to login page return RedirectToAction("UserLogin", "Login"); }