Пример #1
0
        public ActionResult SetAttributeValue(string pk, string value, string name, FormCollection form)
        {
            var success = false;
            var message = string.Empty;

            // name is the entity id of product specification attribute mapping
            var attribute = _specificationAttributeService.GetProductSpecificationAttributeById(Convert.ToInt32(name));

            if (_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                try
                {
                    attribute.SpecificationAttributeOptionId = Convert.ToInt32(value);

                    _specificationAttributeService.UpdateProductSpecificationAttribute(attribute);
                    success = true;
                }
                catch (Exception exception)
                {
                    message = exception.Message;
                }
            }
            else
            {
                NotifyAccessDenied();
            }

            // we give back the name to xeditable to overwrite the grid data in success event when a grid element got updated
            return(Json(new { success = success, message = message, name = attribute.SpecificationAttributeOption?.Name }));
        }
Пример #2
0
        public IActionResult GetProductSpecificationAttributeById(int id, string fields = "")
        {
            if (id <= 0)
            {
                return(Error(HttpStatusCode.BadRequest, "id", "invalid id"));
            }

            var productSpecificationAttribute = _specificationAttributeService.GetProductSpecificationAttributeById(id);

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

            var productSpecificationAttributeDto = _dtoHelper.PrepareProductSpecificationAttributeDto(productSpecificationAttribute);

            var productSpecificationAttributesRootObject = new ProductSpecificationAttributesRootObjectDto();

            productSpecificationAttributesRootObject.ProductSpecificationAttributes.Add(productSpecificationAttributeDto);

            var json = JsonFieldsSerializer.Serialize(productSpecificationAttributesRootObject, fields);

            return(new RawJsonActionResult(json));
        }
Пример #3
0
        public ActionResult SetAttributeValue(string pk, string value, string name, FormCollection form)
        {
            try
            {
                //name is the entity id of product specification attribute mapping
                var specificationAttribute = _specificationAttributeService.GetProductSpecificationAttributeById(Convert.ToInt32(name));
                specificationAttribute.SpecificationAttributeOptionId = Convert.ToInt32(value);
                _specificationAttributeService.UpdateProductSpecificationAttribute(specificationAttribute);
                Response.StatusCode = 200;

                // we give back the name to xeditable to overwrite the grid data in success event when a grid element got updated
                return(Json(new { name = specificationAttribute.SpecificationAttributeOption.Name }));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(501, ex.Message));
            }
        }
        public ActionResult SetAttributeValue(string pk, string value, string name, FormCollection form)
        {
            var success = false;
            var message = string.Empty;

            // name is the entity id of product specification attribute mapping.
            var attribute = _specificationAttributeService.GetProductSpecificationAttributeById(Convert.ToInt32(name));

            try
            {
                attribute.SpecificationAttributeOptionId = Convert.ToInt32(value);

                _specificationAttributeService.UpdateProductSpecificationAttribute(attribute);
                success = true;
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            // we give back the name to xeditable to overwrite the grid data in success event when a grid element got updated.
            return(Json(new { success, message, name = attribute.SpecificationAttributeOption?.Name }));
        }