/// <returns>A task that represents the asynchronous operation</returns> public virtual async Task <IActionResult> CategoryTemplateDelete(int id) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } //try to get a category template with the specified id var template = await _categoryTemplateService.GetCategoryTemplateByIdAsync(id) ?? throw new ArgumentException("No template found with the specified id"); await _categoryTemplateService.DeleteCategoryTemplateAsync(template); return(new NullJsonResult()); }
public virtual async Task <IActionResult> CategoryTemplateDelete(int id) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } if ((await _categoryTemplateService.GetAllCategoryTemplatesAsync()).Count == 1) { return(ErrorJson(await _localizationService.GetResourceAsync("Admin.System.Templates.NotDeleteOnlyOne"))); } //try to get a category template with the specified id var template = await _categoryTemplateService.GetCategoryTemplateByIdAsync(id) ?? throw new ArgumentException("No template found with the specified id"); await _categoryTemplateService.DeleteCategoryTemplateAsync(template); return(new NullJsonResult()); }