private static SimpleJson SaveUserGroup() { string opt = WebUtil.Param("opt"); UserGroup group = new UserGroup(); group.GroupId = WebUtil.ParamInt("id", 0); group.ParentId = WebUtil.ParamInt("parent", 0); group.Name = WebUtil.Param("name"); group.Description = WebUtil.Param("desc"); group.GroupType = (UserGroupType)Enum.Parse(typeof(UserGroupType), WebUtil.Param("type")); group.ModifyBy = SecuritySession.CurrentUser.UserId; group.ModifyTime = DateTime.Now; using (Session session = new Session()) { AuthorizationRepository repository = new AuthorizationRepository(session); switch (opt) { case "create": if (group.ParentId == UserGroup.Root.GroupId) group.GroupLevel = (short)(UserGroup.Root.GroupLevel + 1); else group.GroupLevel = (short)(UserGroup.Retrieve(session, group.ParentId).GroupLevel + 1); group.CreateBy = group.ModifyBy; group.CreateTime = group.ModifyTime; repository.CreateUserGroup(group); break; case "update": if (group.IsRoot) return UserGroup.Root.ToJSON(); group.Update(session, "Name", "Description", "GroupType"); break; } } return group.ToJSON(); }