public JsonResult Data_New() { try { var r = new Role_Record { Title = "新群組" }; var mm = GetMenus(null); r.Menus = mm; return(Json(new { Result = "OK", Message = "Success", Record = r })); } catch (Exception ex) { return(Json(new { Result = "NG", Message = ex.Message })); } }
public JsonResult Role_Save([FromBody] Role_Record record) { try { //新增 if (record.Id == 0) { var role = new AppRole(); role.Title = record.Title; role.Desc = record.Desc; role.Name = Guid.NewGuid().ToString(); var aa = GetCheckAuths(record.Menus); role.AuthMenus = aa.ToJsonText(); _rolem.CreateAsync(role).Wait(); _menusrv.RefreshRoleAuth(role.Name, aa); return(this.Role_Get(role.Id)); } //修改 else { var role = _ctx.Roles.Find(record.Id); var aa = GetCheckAuths(record.Menus); role.Title = record.Title; role.AuthMenus = aa.ToJsonText(); role.Desc = record.Desc; _ctx.SaveChanges(); _menusrv.RefreshRoleAuth(role.Name, aa); return(this.Role_Get(role.Id)); } } catch (Exception ex) { return(Json(new { Result = "NG", Message = ex.Message })); } }