Skip to content

Instantly share code, notes, and snippets.

@sshibani
Created October 13, 2016 12:10
Show Gist options
  • Save sshibani/b0f91f37d053c4ba072cdfaa6c392e5c to your computer and use it in GitHub Desktop.
Save sshibani/b0f91f37d053c4ba072cdfaa6c392e5c to your computer and use it in GitHub Desktop.
public class ProductPriceFieldAttribute : FieldAttributeBase
{
public override IEnumerable GetFieldValues(IField field, IModelProperty property, ITemplate template, IViewModelFactory factory)
{
IEnumerable fieldValue = null;
var productId = field.Values.FirstOrDefault();
var productService = new ProductService();
var price = productService.GetProduct(productId).Price;
return new[] { price };
}
public override Type ExpectedReturnType
{
get
{
return typeof(double);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment