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();
|
var unitsAttribute = attributes.OfType<UnitsAttribute>().FirstOrDefault();
|
||||||
metadata.AdditionalValues.Add("Units", unitsAttribute != null ? unitsAttribute.Text : null);
|
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();
|
var inputSizeAttribute = attributes.OfType<InputSizeAttribute>().FirstOrDefault();
|
||||||
metadata.AdditionalValues.Add("InputSize", inputSizeAttribute != null ? inputSizeAttribute.ClassName : null);
|
metadata.AdditionalValues.Add("InputSize", inputSizeAttribute != null ? inputSizeAttribute.ClassName : null);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
Layout = null;
|
Layout = null;
|
||||||
var lowerPropertyName = @CustomExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName);
|
var lowerPropertyName = @CustomExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName);
|
||||||
var units = (string)ViewData.ModelMetadata.AdditionalValues["Units"];
|
var units = (string)ViewData.ModelMetadata.AdditionalValues["Units"];
|
||||||
|
var currency = (string)ViewData.ModelMetadata.AdditionalValues["Currency"];
|
||||||
var color = ViewData.ModelMetadata.PropertyName == "Color" ? Model : "";
|
var color = ViewData.ModelMetadata.PropertyName == "Color" ? Model : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,13 +13,17 @@
|
|||||||
</dt>
|
</dt>
|
||||||
@if (string.IsNullOrEmpty(color))
|
@if (string.IsNullOrEmpty(color))
|
||||||
{
|
{
|
||||||
<dd>
|
<dd>
|
||||||
@RenderBody()
|
@if (!string.IsNullOrEmpty(currency))
|
||||||
@if (!string.IsNullOrEmpty(units))
|
|
||||||
{
|
{
|
||||||
<small><em>@units</em></small>
|
<small><em>@currency</em></small>
|
||||||
}
|
}
|
||||||
</dd>
|
@RenderBody()
|
||||||
|
@if (!string.IsNullOrEmpty(units))
|
||||||
|
{
|
||||||
|
<small><em>@units</em></small>
|
||||||
|
}
|
||||||
|
</dd>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
var lowerPropertyName = @CustomExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName);
|
var lowerPropertyName = @CustomExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName);
|
||||||
var values = ViewData.ModelMetadata.AdditionalValues;
|
var values = ViewData.ModelMetadata.AdditionalValues;
|
||||||
var units = values.ContainsKey("Units") ? (string)values["Units"] : null;
|
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 formatHint = values.ContainsKey("FormatHint") ? (string)values["FormatHint"] : null;
|
||||||
var editLabel = values.ContainsKey("EditLabel") ? (bool) values["EditLabel"] : true;
|
var editLabel = values.ContainsKey("EditLabel") ? (bool) values["EditLabel"] : true;
|
||||||
}
|
}
|
||||||
@@ -21,6 +22,13 @@
|
|||||||
@RenderBody()
|
@RenderBody()
|
||||||
<span class="add-on">@units</span>
|
<span class="add-on">@units</span>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(currency))
|
||||||
|
{
|
||||||
|
<div class="input-prepend">
|
||||||
|
<span class="add-on">@currency</span>
|
||||||
|
@RenderBody()
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user