public JsonResult Edit(AdminUserInfo model) { if (ModelState.IsValid) { if (AdminService.EditEntity(new AdminInfo { AdminUserId = model.AdminUserId, AdminLoginName = model.AdminLoginName, Email = model.Email, RealName = model.RealName, PhoneNo = model.PhoneNo, RoleId = model.RoleId, LoginPwd = "123456" })) { return Json(new { succeed = 1, msg = "修改成功" }); } else { return Json(new { succeed = -2, msg = "修改失败" }); } } else { return Json(new { succeed = -2, msg = "角色名不能为空" }); } }
public JsonResult Add(AdminUserInfo model) { if (ModelState.IsValid) { AdminInfo adminInfo = AdminService.AddEntity(new AdminInfo { AdminLoginName = model.AdminLoginName, Email = model.Email, RealName = model.RealName, PhoneNo = model.PhoneNo, RoleId = model.RoleId, LoginPwd = "123456" }); if (adminInfo != null) { return Json(new { succeed = "1", msg = "操作成功" }); } else { return Json(new { succeed = "-1", msg = "操作失败" }); } } else { return Json(new { succeed = -2, msg = "角色名不能为空" }); } }
//编辑Get方法 public ActionResult Edit(int id) { AdminInfo adminInfo = AdminService.LoadEntities(x => x.AdminUserId == id).FirstOrDefault(); AdminUserInfo viewRole = new AdminUserInfo(); if (adminInfo != null) { viewRole.AdminUserId = adminInfo.AdminUserId; viewRole.AdminLoginName = adminInfo.AdminLoginName; viewRole.Email = adminInfo.Email; viewRole.PhoneNo = adminInfo.PhoneNo; viewRole.RealName = adminInfo.RealName; viewRole.RoleId = adminInfo.RoleId; ViewData["RoleList"] = GenerateList(); return View("Edit", viewRole); } else { return Content("请求有误"); } }