public virtual Association ToAssociation(catalogDto.ProductAssociation associationDto) { Association result = null; if (associationDto.AssociatedObjectType.EqualsInvariant("product")) { result = new ProductAssociation { ProductId = associationDto.AssociatedObjectId }; } else if (associationDto.AssociatedObjectType.EqualsInvariant("category")) { result = new CategoryAssociation { CategoryId = associationDto.AssociatedObjectId }; } if (result != null) { result.Type = associationDto.Type; result.Priority = associationDto.Priority ?? 0; result.Image = new Image { Url = associationDto.AssociatedObjectImg }; result.Quantity = associationDto.Quantity; } return(result); }
public static Association ToWebModel(this catalogModel.ProductAssociation association) { Association retVal = null; if (association.AssociatedObjectType.EqualsInvariant("product")) { retVal = new ProductAssociation { ProductId = association.AssociatedObjectId }; } else if (association.AssociatedObjectType.EqualsInvariant("category")) { retVal = new CategoryAssociation { CategoryId = association.AssociatedObjectId }; } if (retVal != null) { retVal.InjectFrom <NullableAndEnumValueInjecter>(association); retVal.Image = new Image { Url = association.AssociatedObjectImg }; } return(retVal); }