Exemplo n.º 1
0
 public static SkuAttributeView ToVIew(SkuAttribute attribute)
 {
     if (attribute != null)
     {
         SkuAttributeView view = new SkuAttributeView
         {
             name  = attribute.Attribute == null ? string.Empty : attribute.Attribute.Name,
             value = attribute.AttributeValue == null ? string.Empty : attribute.AttributeValue.Value
         };
         return(view);
     }
     return(null);
 }
Exemplo n.º 2
0
        private SkuAttribute GetSkuAttribute(IGrouping <Guid, EntityData> group)
        {
            var details = new SkuAttributeAttributeValues
            {
                lang          = EnUs,
                ValueElements =
                    new List <SkuAttributeAttributeValuesValueElement>()
            };
            var skuAttr = new SkuAttribute
            {
                //Id = group.First().AttributeID,
                AttributeId      = group.Key,
                AttributeValuess = new List <SkuAttributeAttributeValues>(new[] { details })
            };

            foreach (var entityData in group)
            {
                var val = new SkuAttributeAttributeValuesValueElement
                {
                    Id    = entityData.EntityID,
                    Value =
                        new MeasuredValueType
                    {
                        Value = entityData.Value,
                        UoM   = entityData.Uom ?? string.Empty
                    },
                    MetaDatums = new List <MetaDatumType>()
                };

                if (!string.IsNullOrWhiteSpace(entityData.Field1))
                {
                    val.MetaDatums.Add(new MetaDatumType
                    {
                        Name  = _project.EntityField1Name ?? "Field 1",
                        Value = entityData.Field1
                    });
                }
                if (!string.IsNullOrWhiteSpace(entityData.Field2))
                {
                    val.MetaDatums.Add(new MetaDatumType
                    {
                        Name  = _project.EntityField2Name ?? "Field 2",
                        Value = entityData.Field2
                    });
                }
                if (!string.IsNullOrWhiteSpace(entityData.Field3))
                {
                    val.MetaDatums.Add(new MetaDatumType
                    {
                        Name  = _project.EntityField3Name ?? "Field 3",
                        Value = entityData.Field3
                    });
                }
                if (!string.IsNullOrWhiteSpace(entityData.Field4))
                {
                    val.MetaDatums.Add(new MetaDatumType
                    {
                        Name  = _project.EntityField4Name ?? "Field 4",
                        Value = entityData.Field4
                    });
                }

                if (_project.EntityField5IsStatus)
                {
                    val.StatusFlag = entityData.Field5OrStatus;
                }
                else if (!string.IsNullOrWhiteSpace(entityData.Field5))
                {
                    val.MetaDatums.Add(new MetaDatumType
                    {
                        Name  = _project.EntityField5Name ?? "Field 5",
                        Value = entityData.Field5OrStatus
                    });
                }

                details.ValueElements.Add(val);
            }

            return(skuAttr);
        }