public void Delete(int id) { SysRoleInfo entity = this.GetEntity(id); db.Entry(entity).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); }
public bool Update(SysRoleInfo info) { if (info.RoleId != 0) { return(_repo.Update(info).Result); } else { return(_repo.Add(info).Result); } }
//新增 public ActionResult AddRole() { string name = Request.Form["name"]; if (string.IsNullOrEmpty(name)) { return(Json(new { code = "0", msg = "角色名不能为空" })); } var model = roleInfoMan.GetModelByUsername(name); if (model != null) { return(Json(new { code = "1", msg = "角色名已存在" })); } string code = Request.Form["code"]; if (string.IsNullOrEmpty(code)) { return(Json(new { code = "0", msg = "角色代码不能为空" })); } model = roleInfoMan.GetModelByCode(code); if (model != null) { return(Json(new { code = "2", msg = "角色代码已存在" })); } string abbr = Request.Form["abbr"] ?? ""; string desc = Request.Form["desc"] ?? ""; model = new SysRoleInfo() { Abbreviation = abbr, Code = code, Name = name, CreateTime = DateTime.Now, Description = desc }; roleInfoMan.Add(model); return(Json(new { code = "200", msg = "新增成功" })); }
public void Delete(SysRoleInfo entity) { db.Entry(entity).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); }
public void Update(SysRoleInfo entity) { db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public void Add(SysRoleInfo entity) { db.SysRoleInfos.Add(entity); db.SaveChanges(); }