Ejemplo n.º 1
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> Delete(int id)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageAttributes))
            {
                return(AccessDeniedView());
            }

            //try to get a product attribute with the specified id
            var productAttribute = await _productAttributeService.GetProductAttributeByIdAsync(id);

            if (productAttribute == null)
            {
                return(RedirectToAction("List"));
            }

            await _productAttributeService.DeleteProductAttributeAsync(productAttribute);

            //activity log
            await _customerActivityService.InsertActivityAsync("DeleteProductAttribute",
                                                               string.Format(await _localizationService.GetResourceAsync("ActivityLog.DeleteProductAttribute"), productAttribute.Name), productAttribute);

            _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Catalog.Attributes.ProductAttributes.Deleted"));

            return(RedirectToAction("List"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DeleteProductAttribute(int id)
        {
            if (id <= 0)
            {
                return(Error(HttpStatusCode.BadRequest, "id", "invalid id"));
            }

            var productAttribute = await _productAttributesApiService.GetByIdAsync(id);

            if (productAttribute == null)
            {
                return(Error(HttpStatusCode.NotFound, "product attribute", "not found"));
            }

            await _productAttributeService.DeleteProductAttributeAsync(productAttribute);

            //activity log
            await CustomerActivityService.InsertActivityAsync("DeleteProductAttribute", await LocalizationService.GetResourceAsync("ActivityLog.DeleteProductAttribute"),
                                                              productAttribute);

            return(new RawJsonActionResult("{}"));
        }