I've currently got all of this mess at the top of my ViewModels which I feel violates the purpose of a DTO. For example, this is in the constructor of one of my view models -
Dictionary<int, string> chargeGroups = new Dictionary<int, string>();
chargeGroups.Add(1, "Administration");
chargeGroups.Add(2, "Annual Leave");
chargeGroups.Add(3, "Bereavement");
chargeGroups.Add(4, "Customer Installation, Setup & Training");
chargeGroups.Add(5, "Customer Support");
chargeGroups.Add(6, "Internal Training & Education");
chargeGroups.Add(7, "Sales & Marketing");
chargeGroups.Add(8, "Sick");
chargeGroups.Add(9, "Software Devel / Maint / Test");
chargeGroups.Add(10, "Software Upgrade / Patch");
chargeGroups.Add(11, "Other");
chargeGroups.Add(12, "Other Absence");
chargeGroups.Add(13, "Warranty");
chargeGroups.Add(14, "Public Holiday");
chargeGroups.Add(15, "Other Paid Leave");
ChargeGroups = new SelectList(chargeGroups, "Key", "Value");
My viewmodel:
[DisplayName("Charge group")]
public short? ChargeGroup { get; set; }
public SelectList ChargeGroups;
then in my view:
<div class="editor-label">
@Html.LabelFor(model => model.ChargeGroup)
</div>
<div class="editor-field">
@Html.DropDownListFor(model => model.ChargeGroup, Model.ChargeGroups)
@Html.ValidationMessageFor(model => model.ChargeGroup)
</div>
Where should I be putting this stuff?