コード例 #1
0
        public ActionResult AddNewAdmin(ValidateAdmin vAdmin, FormCollection form)
        {
            ViewData["Role"] = GetRoleForView();

            if (ModelState.IsValid)
            {
                RepositoryOBTRS db     = new RepositoryOBTRS();
                Boolean         active = true;
                if (form.Get("Active") == "false")
                {
                    active = false;
                }
                String result = db.AddNewAdmin(
                    form.Get("Role"),
                    form.Get("AdminName"),
                    DateTime.Parse(form.Get("DateOfBirth")),
                    form.Get("Password"),
                    form.Get("Address"),
                    form.Get("Phone"),
                    form.Get("Email"),
                    form.Get("Description"),
                    active
                    );
                if (result == "")
                {
                    //Neu them admin thanh cong
                    return(Redirect("/CMS/ManagerList"));
                }
                else
                {
                    //Neu gap truc trac ko the them Admin
                    ViewData["Error"] = result;
                    return(View(vAdmin));
                }
            }

            //Neu gia tri nhap vao ko dung
            return(View(vAdmin));
        }