Example #1
0
        public void Delete(int id)
        {
            SysRoleInfo entity = this.GetEntity(id);

            db.Entry(entity).State = System.Data.Entity.EntityState.Deleted;
            db.SaveChanges();
        }
Example #2
0
 public bool Update(SysRoleInfo info)
 {
     if (info.RoleId != 0)
     {
         return(_repo.Update(info).Result);
     }
     else
     {
         return(_repo.Add(info).Result);
     }
 }
Example #3
0
        //新增
        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 = "新增成功" }));
        }
Example #4
0
 public void Delete(SysRoleInfo entity)
 {
     db.Entry(entity).State = System.Data.Entity.EntityState.Deleted;
     db.SaveChanges();
 }
Example #5
0
 public void Update(SysRoleInfo entity)
 {
     db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Example #6
0
 public void Add(SysRoleInfo entity)
 {
     db.SysRoleInfos.Add(entity);
     db.SaveChanges();
 }