public ProductSpecificationMappingViewModel()
 {
     SpecificationAttributeType  = new SpecificationAttributeType();
     SpecificationAttributeValue = new List <SelectListItem>();
     SpecificationAttribute      = new List <SelectListItem>();
     ShowOnProductPage           = true;
 }
Exemplo n.º 2
0
        public async Task <ActionResult> ProductSpecAttrList(DataSourceRequest command, int productId)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedKendoGridJson();
            TEBApiResponse apiResponse = await Get("/Product/GetProductSpecificationAttributes?productId=" + productId);

            if (apiResponse.IsSuccess)
            {
                List <Product_SpecificationAttribute_Mapping> productSpecificationAttribute = JsonConvert.DeserializeObject <List <Product_SpecificationAttribute_Mapping> >(Convert.ToString(apiResponse.Data));
                var productrSpecsModel = productSpecificationAttribute
                                         .Select(x =>
                {
                    var psaModel = new Product_SpecificationAttribute_MappingViewModel
                    {
                        Id = x.Id,
                        AttributeTypeId = x.AttributeTypeId,
                        // AttributeTypeName = ,
                        //AttributeId = x.SpecificationAttributeOption.SpecificationAttribute.Id,
                        //AttributeName = x.SpecificationAttributeOption.SpecificationAttribute.Name,
                        AllowFiltering    = x.AllowFiltering,
                        ShowOnProductPage = x.ShowOnProductPage,
                        DisplayOrder      = x.DisplayOrder
                    };
                    SpecificationAttributeType AttributeType = ((SpecificationAttributeType)x.AttributeTypeId);

                    switch (AttributeType)
                    {
                    case SpecificationAttributeType.Option:
                        psaModel.ValueRaw = HttpUtility.HtmlEncode(Enum.Parse(typeof(SpecificationAttributeOption), x.SpecificationAttributeOptionId.ToString()));
                        psaModel.SpecificationAttributeOptionId = x.SpecificationAttributeOptionId;
                        break;

                    case SpecificationAttributeType.CustomText:
                        psaModel.ValueRaw = HttpUtility.HtmlEncode(x.CustomValue);
                        break;

                    case SpecificationAttributeType.CustomHtmlText:
                        //do not encode?
                        //psaModel.ValueRaw = x.CustomValue;
                        psaModel.ValueRaw = HttpUtility.HtmlEncode(x.CustomValue);
                        break;

                    case SpecificationAttributeType.Hyperlink:
                        psaModel.ValueRaw = x.CustomValue;
                        break;

                    default:
                        break;
                    }
                    return(psaModel);
                })
                                         .ToList();

                var gridModel = new DataSourceResult
                {
                    Data  = productrSpecsModel,
                    Total = productrSpecsModel.Count
                };
                return(Json(gridModel));
            }

            return(Json(0));
        }