Add currency attribute
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace MileageTraker.Web.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||
public class CurrencyAttribute : Attribute
|
||||
{
|
||||
public string Symbol
|
||||
{
|
||||
get { return "$"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,9 @@ namespace MileageTraker.Web
|
||||
var unitsAttribute = attributes.OfType<UnitsAttribute>().FirstOrDefault();
|
||||
metadata.AdditionalValues.Add("Units", unitsAttribute != null ? unitsAttribute.Text : null);
|
||||
|
||||
var currencyAttribute = attributes.OfType<CurrencyAttribute>().FirstOrDefault();
|
||||
metadata.AdditionalValues.Add("Currency", currencyAttribute != null ? currencyAttribute.Symbol : null);
|
||||
|
||||
var inputSizeAttribute = attributes.OfType<InputSizeAttribute>().FirstOrDefault();
|
||||
metadata.AdditionalValues.Add("InputSize", inputSizeAttribute != null ? inputSizeAttribute.ClassName : null);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Layout = null;
|
||||
var lowerPropertyName = @CustomExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName);
|
||||
var units = (string)ViewData.ModelMetadata.AdditionalValues["Units"];
|
||||
var currency = (string)ViewData.ModelMetadata.AdditionalValues["Currency"];
|
||||
var color = ViewData.ModelMetadata.PropertyName == "Color" ? Model : "";
|
||||
}
|
||||
|
||||
@@ -12,13 +13,17 @@
|
||||
</dt>
|
||||
@if (string.IsNullOrEmpty(color))
|
||||
{
|
||||
<dd>
|
||||
@RenderBody()
|
||||
@if (!string.IsNullOrEmpty(units))
|
||||
<dd>
|
||||
@if (!string.IsNullOrEmpty(currency))
|
||||
{
|
||||
<small><em>@units</em></small>
|
||||
<small><em>@currency</em></small>
|
||||
}
|
||||
</dd>
|
||||
@RenderBody()
|
||||
@if (!string.IsNullOrEmpty(units))
|
||||
{
|
||||
<small><em>@units</em></small>
|
||||
}
|
||||
</dd>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
var lowerPropertyName = @CustomExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName);
|
||||
var values = ViewData.ModelMetadata.AdditionalValues;
|
||||
var units = values.ContainsKey("Units") ? (string)values["Units"] : null;
|
||||
var currency = values.ContainsKey("Currency") ? (string)values["Currency"] : null;
|
||||
var formatHint = values.ContainsKey("FormatHint") ? (string)values["FormatHint"] : null;
|
||||
var editLabel = values.ContainsKey("EditLabel") ? (bool) values["EditLabel"] : true;
|
||||
}
|
||||
@@ -21,6 +22,13 @@
|
||||
@RenderBody()
|
||||
<span class="add-on">@units</span>
|
||||
</div>
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(currency))
|
||||
{
|
||||
<div class="input-prepend">
|
||||
<span class="add-on">@currency</span>
|
||||
@RenderBody()
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user