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 EditPartnerBranchAtDashboard(EditPartnerBranceModel model, string branchCode) { if (userData.RoleId != 1 && userData.RoleId != 2) { return RedirectToAction("UserDetails", "UserManagement"); } CompanyBranchModel nonRegBranch = model.CompanyBranch; nonRegBranch.MainBranch.StateId = model.StateId; nonRegBranch.MainBranch.BranchCode = branchCode; nonRegBranch.MainBranch.BranchCreatedBy = model.RegBranchId; nonRegBranch.MainBranch.BranchCompany = model.NonRegCompanyId; BranchAccess ba = new BranchAccess(); int reslt = ba.insertNonRegBranchDetails(nonRegBranch, userData.UserId); if (reslt > 0) { if (_compType == 1) { ViewBag.SuccessMsg = "Dealer branch is successfully updated"; } else if (_compType == 2) { ViewBag.SuccessMsg = "Lender branch is successfully updated"; } if (Session["loanDashboard"] != null) { if (((Loan)Session["loanDashboard"]).NonRegBranchId == model.CompanyBranch.MainBranch.NonRegBranchId) { ((Loan)Session["loanDashboard"]).PartnerName = model.NonRegCompanyName+" - "+model.CompanyBranch.MainBranch.BranchName; } } else if (Session["LoanOne"] != null) { if (((Loan)Session["LoanOne"]).NonRegBranchId == model.CompanyBranch.MainBranch.NonRegBranchId) { ((Loan)Session["LoanOne"]).PartnerName = model.NonRegCompanyName + " - " + model.CompanyBranch.MainBranch.BranchName; } } return RedirectToAction("EditPartnerBranchAtDashboard", new { lbls = ViewBag.SuccessMsg }); } else { ViewBag.ErrorMsg = "Failed to update"; return RedirectToAction("EditPartnerBranchAtDashboard", new { lbls = ViewBag.ErrorMsg }); } }
public ActionResult CreatePartnerBranchAtDashboard(EditPartnerBranceModel model) { if (userData.RoleId != 1 && userData.RoleId != 2) { return RedirectToAction("UserDetails", "UserManagement"); } CompanyBranchModel nonRegBranch = model.CompanyBranch; nonRegBranch.MainBranch.StateId = model.StateId; nonRegBranch.MainBranch.BranchCreatedBy = model.RegBranchId; nonRegBranch.MainBranch.BranchCompany = model.NonRegCompanyId; CompanyAccess ca = new CompanyAccess(); BranchAccess ba = new BranchAccess(); Company company = ca.GetNonRegCompanyByCompanyId(model.NonRegCompanyId); //nonRegBranch.MainBranch.BranchCode = ba.createNonRegBranchCode(company.CompanyCode); int reslt = ba.insertNonRegBranchDetails(nonRegBranch, userData.UserId, company.CompanyCode); if (reslt > 0) { //update Companay Step States in incomplete Branches continued in dashboard StepAccess sa = new StepAccess(); sa.UpdateLoanSetupStep(userData.UserId, userData.Company_Id, model.RegBranchId, reslt, 0, 1); if (_compType == 1) { ViewBag.SuccessMsg = "Dealer branch is successfully inserted"; } else if (_compType == 2) { ViewBag.SuccessMsg = "Lender branch is successfully inserted"; } return RedirectToAction("CreatePartnerBranchAtDashboard", new { lbls = ViewBag.SuccessMsg }); } else { ViewBag.ErrorMsg = "Failed to udate"; return RedirectToAction("CreatePartnerBranchAtDashboard", new { lbls = ViewBag.ErrorMsg }); } }