public ActionResult Edit(int id,string name,string role) { AdminType adminType = new AdminType(); if (string.IsNullOrEmpty(name)) { hitStr = "名称不能空!"; } else { using (club = new ClubEntities()) { adminType = club.AdminTypes.Where(t => t.Id == id).FirstOrDefault(); adminType.Name = name; adminType.Role = role; if (club.SaveChanges() > 0) { status = Status.success; hitStr = "更新成功!"; } else { hitStr = "系统异常,更新失败!"; } } if (adminType == null) RedirectToAction("notfound", "error"); ViewBag.AdminType = adminType; } ViewBag.StatusStr = Common.HtmlCommon.GetHitStr(hitStr, status); return View("~/areas/bwum/views/level/create.cshtml", GetRole()); }
public ActionResult Edit(int? id) { tId = id ?? 0; AdminType adminType = new AdminType(); using (club = new ClubEntities()) { adminType = club.AdminTypes.Where(t => t.Id == tId).FirstOrDefault(); } if (adminType == null) RedirectToAction("notfound","error"); ViewBag.AdminType = adminType; return View("~/areas/bwum/views/level/create.cshtml",GetRole()); }
public ActionResult Create(string name, string role) { if (string.IsNullOrEmpty(name)) { hitStr = "名称不能为空!"; } else { AdminType adminType = new AdminType { Name=name,Role=role,VarDate=DateTime.Now}; using (club = new ClubEntities()) { club.AdminTypes.Add(adminType); if (club.SaveChanges() > 0) { hitStr = "创建成功!"; status = Status.success; } else { hitStr = "系统异常,请稍后重试!"; } } } ViewBag.StatusStr = Common.HtmlCommon.GetHitStr(hitStr, status); return View(GetRole()); }