I want to attach a Part to a content item, let's say Priority. The part is PriorityPart. I want the PriorityPart to take a string field Priority from a different table. Let's say PropertyPartRecord.
I was able to get the data from the propertyPartRecord table but I can't sent the data into it.
Here's my classes.
PriorityPartDriver:
protected override DriverResult Editor(PriorityPart part, IUpdateModel updater, dynamic shapeHelper)
{
var model = new EditPriorityViewModel();
updater.TryUpdateModel(model, Prefix, null, null);
return ContentShape("Parts_Priority_Edit",
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
}
EditPriorityViewModel:
public class EditPriorityViewModel
{
public string Priority { get; set; }
}
PriorityPart:
public class PriorityPart : ContentPart<PropertyPartRecord>
{
public string CurrentPriority { get { return Record.Priority; } }
}
PropertyPartRecord:
public class PropertyPartRecord:ContentPartRecord
{
public PropertyPartRecord()
{
Priority = "1";
}
public virtual String Priority { get; set; }
}
Editor View Priority:
@model ePageo.TUI.MediaManager.ViewModels.EditPriorityViewModel
<fieldset>
@Html.LabelFor(m => m.Priority, T("Priority"))
@Html.TextBoxFor(m => m.Priority, new { @class = "text large" })
@*@Html.DropDownListFor(m => m.Priorities.SelectedValue,@Model.Priorities)*@
@*@Html.DropDownListFor(n => n.OrderTemplates, new SelectList(Model.OrderTemplates, "OrderTemplateId", "OrderTemplateName", 1), "Please select an order template")*@
<span class="hint">@T("Please provide a numeric priority for the media item. 1 being highest priority and 100 being the lowest. Default is 1.")</span>
</fieldset>
I just couldn't add data into the PropertyPartRecord table. It does add the default value of 1 but then it never updates.
I can't figure out what I'm doing wrong.
I'm doing it this way because I'd later add more fields to the PropertyPartRecord table which may or may not have its own parts.