Пример #1
0
        public virtual async Task <IActionResult> EditSpecificationAttributeGroup(SpecificationAttributeGroupModel model, bool continueEditing)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageAttributes))
            {
                return(AccessDeniedView());
            }

            var specificationAttributeGroup = await _specificationAttributeService.GetSpecificationAttributeGroupByIdAsync(model.Id);

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

            if (ModelState.IsValid)
            {
                specificationAttributeGroup = model.ToEntity(specificationAttributeGroup);
                await _specificationAttributeService.UpdateSpecificationAttributeGroupAsync(specificationAttributeGroup);
                await UpdateAttributeGroupLocalesAsync(specificationAttributeGroup, model);

                await _customerActivityService.InsertActivityAsync("EditSpecAttributeGroup",
                                                                   string.Format(await _localizationService.GetResourceAsync("ActivityLog.EditSpecAttributeGroup"), specificationAttributeGroup.Name), specificationAttributeGroup);

                _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Catalog.Attributes.SpecificationAttributes.SpecificationAttributeGroup.Updated"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                return(RedirectToAction("EditSpecificationAttributeGroup", new { id = specificationAttributeGroup.Id }));
            }

            model = await _specificationAttributeModelFactory.PrepareSpecificationAttributeGroupModelAsync(model, specificationAttributeGroup, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }