/// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> ManufacturerTemplateDelete(int id)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            //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());
        }
Exemplo n.º 2
0
        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());
        }