async Task <ICommandResultBase> InstallCategoryAsync(IShellFeature feature, int sortOrder = 0) { // Validate if (feature == null) { throw new ArgumentNullException(nameof(feature)); } if (string.IsNullOrEmpty(feature.ModuleId)) { throw new ArgumentNullException(nameof(feature.ModuleId)); } // Our result var result = new CommandResultBase(); var icons = new DefaultIcons(); var foreColor = "#ffffff"; var backColor = $"#{_colorProvider.GetColor()}"; var iconCss = $"fal fa-{icons.GetIcon()}"; var categoryResult = await _categoryManager.CreateAsync(new CategoryBase() { FeatureId = feature.Id, ParentId = 0, Name = $"Example Category {_random.Next(0, 2000).ToString()}", Description = $"This is just an example category desccription.", ForeColor = foreColor, BackColor = backColor, IconCss = iconCss, SortOrder = sortOrder }); if (!categoryResult.Succeeded) { return(result.Failed(result.Errors.ToArray())); } return(result.Success()); }
public override async Task <IViewProviderResult> BuildEditAsync(CategoryAdmin categoryBase, IViewProviderContext updater) { var defaultIcons = new DefaultIcons(); EditChannelViewModel editChannelViewModel = null; if (categoryBase.Id == 0) { editChannelViewModel = new EditChannelViewModel() { IconPrefix = defaultIcons.Prefix, ChannelIcons = defaultIcons, IsNewChannel = true, ParentId = categoryBase.ParentId, AvailableChannels = await GetAvailableCategories() }; } else { editChannelViewModel = new EditChannelViewModel() { Id = categoryBase.Id, ParentId = categoryBase.ParentId, Name = categoryBase.Name, Description = categoryBase.Description, ForeColor = categoryBase.ForeColor, BackColor = categoryBase.BackColor, IconCss = categoryBase.IconCss, IconPrefix = defaultIcons.Prefix, ChannelIcons = defaultIcons, AvailableChannels = await GetAvailableCategories() }; } return(Views( View <EditChannelViewModel>("Admin.Edit.Header", model => editChannelViewModel).Zone("header").Order(1), View <EditChannelViewModel>("Admin.Edit.Content", model => editChannelViewModel).Zone("content").Order(1), View <EditChannelViewModel>("Admin.Edit.Actions", model => editChannelViewModel).Zone("actions").Order(1), View <EditChannelViewModel>("Admin.Edit.Footer", model => editChannelViewModel).Zone("footer").Order(1) )); }