public bool AddNewRole(string name) { if (RoleExist(name)) { return(true); } else { ApplicationRole r = new ApplicationRole(name); using (var db = new ApplicationDbContext()) { db.Roles.Add(r); return(db.SaveChanges() > 0); } //roleStore.Roles } throw new NotImplementedException(); }
/// <summary> /// remv by rolename. /// </summary> /// <param name="id"></param> /// <returns></returns> public int DelRole(string id) { if (!string.IsNullOrEmpty(id) && RoleStore.Roles.Any(a => a.Name == id)) { using (var db = new ApplicationDbContext()) { if (id == AppConfigs.AppRole.sys.ToString()) { return(0); } var md = db.Roles.SingleOrDefault(a => a.Name == id); db.Roles.Remove(md); return(db.SaveChanges()); } } return(0); }