コード例 #1
0
        public ActionResult Setup(Company company)
        {
            if (Session["type"] == null)
            {
                return(RedirectToAction("UserLogin", "Login"));
            }

            //if (type == "CompanyEmployee")
            //{

            //}

            GeneratesCode gc = new GeneratesCode();

            company.CompanyCode = gc.GenerateCompanyCode(company.CompanyName);

            UserCompanyModel userCom = new UserCompanyModel();

            userCom.User = _user;

            company.Zip = company.ZipPre;
            if (company.Extension != null)
            {
                company.Zip += "-" + company.Extension;
            }

            userCom.Company = company;

            TempData["UserCompany"] = userCom;
            return(RedirectToAction("CreateBranchFirstBranch", "CreateBranch", new { id = 0, type = "CompanyEmployee" }));
        }
コード例 #2
0
        public ActionResult Step1(Company company, int?edit)
        {
            if (Session["userId"] == null || Session["userId"].ToString() == "")
            {
                return(RedirectToAction("UserLogin", "Login"));
            }


            string type;

            if (edit != 1)
            {
                GeneratesCode gc = new GeneratesCode();
                _comCode = company.CompanyCode = gc.GenerateCompanyCode(company.CompanyName);
                type     = "INSERT";
            }
            else
            {
                company.CompanyCode = _comCode;
                type = "UPDATE";
            }

            //
            company.Zip = company.ZipPre;
            if (company.Extension != null)
            {
                company.Zip += "-" + company.Extension;
            }

            company.CreatedBy     = company.FirstSuperAdminId = Convert.ToInt32(Session["userId"]);
            company.CompanyStatus = true;
            CompanyAccess ca = new CompanyAccess();

            //check this record is new one or exitsting one
            //string type = (edit == 1) ? "UPDATE" : "INSERT";

            int companyId = ca.InsertCompany(company, type);

            if (companyId > 0)
            {
                ViewBag.SuccessMsg = "Company Successfully setup.";

                CompanyType = (company.TypeId == 1) ? "Lender" : "Dealer";

                //If succeed update step table to step2
                StepAccess sa = new StepAccess();
                sa.updateStepNumberByUserId(company.FirstSuperAdminId, 2);

                //Send company detail to step 2
                CompanyBranchModel comBranch = new CompanyBranchModel();
                comBranch.Company = company;

                TempData["Company"] = comBranch;

                return(RedirectToAction("Step2"));
            }
            ViewBag.ErrorMsg = "Failed to Setup company.";

            // Get company types to list
            List <CompanyType> ctList = ca.GetAllCompanyType();

            ViewBag.TypeId = new SelectList(ctList, "TypeId", "TypeName");

            //Get states to list
            List <State> stateList = ca.GetAllStates();

            ViewBag.StateId = new SelectList(stateList, "StateId", "StateName");

            return(View());
        }