Beispiel #1
0
        private static ParametricModel MapProductParametric(ProductParametric p, ParametricInfo pi)
        {
            var parametric = new ParametricModel
            {
                Id          = p.Id,
                Name        = p.Name,
                Description = p.Description,
                Uom         = p.Uom,
                IsPrimary   = p.IsPrimary,
                GroupId     = p.GroupId,
                Group       = p.GroupName,
                ValueType   = pi.ValueType,
                Code        = pi.Code,
                Values      = new List <ParametricValueModel>()
            };

            return(parametric);
        }
Beispiel #2
0
        private ParametricModel MapParametric(ProductParametric p)
        {
            var parametricInfo = dictionary.ParametricInfo(p.Id, StormContext.CultureCode);

            if (parametricInfo.Type == ParametricType.ListValue)
            {
                if (p.ValueId == null)
                {
                    return(null);
                }

                var parametric      = MapProductParametric(p, parametricInfo);
                var parametricValue = dictionary.ParametricValue(parametricInfo.Type, p.ValueId.Value, StormContext.CultureCode);
                if (parametricValue == null)
                {
                    return(parametric);
                }
                var value = MapProductParametricValue(parametricValue);
                parametric.Values.Add(value);
                return(parametric);
            }

            if (parametricInfo.Type == ParametricType.MultiValue)
            {
                if (string.IsNullOrWhiteSpace(p.ValueIdSeed))
                {
                    return(null);
                }
                var parametric = MapProductParametric(p, parametricInfo);
                foreach (var v in p.ValueIdSeed.Split(','))
                {
                    int id;
                    if (!int.TryParse(v, out id))
                    {
                        return(null);
                    }
                    var parametricValue = dictionary.ParametricValue(parametricInfo.Type, id, StormContext.CultureCode);
                    if (parametricValue == null)
                    {
                        continue;
                    }
                    var value = MapProductParametricValue(parametricValue);
                    parametric.Values.Add(value);
                }
                return(parametric);
            }

            if (p.ValueId.HasValue)
            {
                var value = new ParametricValueModel {
                    Id = p.ValueId.Value, Value = p.Value2 ?? "",
                };
                var parametric = MapProductParametric(p, parametricInfo);
                parametric.Values.Add(value);
                return(parametric);
            }
            else
            {
                var value = new ParametricValueModel {
                    Value = p.Value2 ?? ""
                };
                var parametric = MapProductParametric(p, parametricInfo);
                parametric.Values.Add(value);
                return(parametric);
            }
        }