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

            //try to get a product template with the specified id
            var template = await _productTemplateService.GetProductTemplateByIdAsync(id)
                           ?? throw new ArgumentException("No template found with the specified id");

            await _productTemplateService.DeleteProductTemplateAsync(template);

            return(new NullJsonResult());
        }
Ejemplo n.º 2
0
        public virtual async Task <IActionResult> ProductTemplateDelete(int id)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if ((await _productTemplateService.GetAllProductTemplatesAsync()).Count == 1)
            {
                return(ErrorJson(await _localizationService.GetResourceAsync("Admin.System.Templates.NotDeleteOnlyOne")));
            }

            //try to get a product template with the specified id
            var template = await _productTemplateService.GetProductTemplateByIdAsync(id)
                           ?? throw new ArgumentException("No template found with the specified id");

            await _productTemplateService.DeleteProductTemplateAsync(template);

            return(new NullJsonResult());
        }