Exemplo n.º 1
0
        //[HttpGet]
        public ActionResult EditAdmin(String adminID, ValidateAdmin vAdmin, FormCollection form)
        {
            try
            {
                ViewData["Role"] = GetRoleForView();

                if (ModelState.IsValid)
                {
                    RepositoryOBTRS db     = new RepositoryOBTRS();
                    Boolean         active = true;
                    if (form.Get("Active") == "false")
                    {
                        active = false;
                    }
                    String result = db.UpdateAdmin(
                        adminID,
                        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 cap nhat admin thanh cong
                        return(Redirect("/CMS/ManagerList"));
                    }
                    else
                    {
                        //Neu gap truc trac ko the cap nhat Admin
                        ViewData["Error"] = result;
                        return(View(vAdmin));
                    }
                }
            }
            catch (Exception)
            {
                return(Redirect("/CMS/"));
            }
            //Neu gia tri nhap vao ko dung
            return(View(vAdmin));
        }