/// <summary> /// Prepare paged manufacturer template list model /// </summary> /// <param name="searchModel">Manufacturer template search model</param> /// <returns>Manufacturer template list model</returns> public virtual async Task <ManufacturerTemplateListModel> PrepareManufacturerTemplateListModelAsync(ManufacturerTemplateSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get manufacturer templates var manufacturerTemplates = (await _manufacturerTemplateService.GetAllManufacturerTemplatesAsync()).ToPagedList(searchModel); //prepare grid model var model = new ManufacturerTemplateListModel().PrepareToGrid(searchModel, manufacturerTemplates, () => manufacturerTemplates.Select(template => template.ToModel <ManufacturerTemplateModel>())); return(model); }
public virtual async Task <IActionResult> ManufacturerTemplateDelete(int id) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } if ((await _manufacturerTemplateService.GetAllManufacturerTemplatesAsync()).Count == 1) { return(ErrorJson(await _localizationService.GetResourceAsync("Admin.System.Templates.NotDeleteOnlyOne"))); } //try to get a manufacturer template with the specified id var template = await _manufacturerTemplateService.GetManufacturerTemplateByIdAsync(id) ?? throw new ArgumentException("No template found with the specified id"); await _manufacturerTemplateService.DeleteManufacturerTemplateAsync(template); return(new NullJsonResult()); }