コード例 #1
0
ファイル: MenuAdminManager.cs プロジェクト: P9os/SunEngine
        public virtual async Task CreateAsync(MenuItem menuItem)
        {
            if (menuItem.ParentId == 0)
            {
                menuItem.ParentId = null;
            }


            menuItem.Name            = menuItem.Name?.SetNullIfEmptyTrim();
            menuItem.Title           = menuItem.Title?.SetNullIfEmptyTrim();
            menuItem.SubTitle        = menuItem.SubTitle?.SetNullIfEmptyTrim();
            menuItem.RouteName       = menuItem.RouteName?.SetNullIfEmptyTrim();
            menuItem.RouteParamsJson = menuItem.RouteParamsJson?.MakeJsonText();
            menuItem.SettingsJson    = menuItem.SettingsJson?.MakeJsonText();
            menuItem.CssClass        = menuItem.CssClass?.SetNullIfEmptyTrim();
            menuItem.ExternalUrl     = menuItem.ExternalUrl?.SetNullIfEmptyTrim();
            menuItem.Icon            = menuItem.Icon?.SetNullIfEmptyTrim();
            menuItem.Roles           = rolesCache.CheckAndSetRoles(menuItem.Roles);


            using (db.BeginTransaction())
            {
                int id = await db.InsertWithInt32IdentityAsync(menuItem);

                await db.MenuItems.Where(x => x.Id == id).Set(x => x.SortNumber, x => id).UpdateAsync();

                db.CommitTransaction();
            }
        }
コード例 #2
0
        public Task CreateComponentAsync(Component component)
        {
            component.ClientSettingsJson = component.ClientSettingsJson?.MakeJsonTextNotNull();
            component.ServerSettingsJson = component.ServerSettingsJson?.MakeJsonTextNotNull();
            component.Roles = rolesCache.CheckAndSetRoles(component.Roles);

            return(db.InsertWithIdentityAsync(component));
        }