I've got a ToDo class which has properties for Staff and Priority. If a user updates a ToDo item, changes the TaskName and maybe sets a new Priority how do I update the Priority property -
public class ToDo : BaseEntity
{
public DateTime? DueDate { get; set; }
public String Notes { get; set; }
public virtual Priority Priority { get; set; }
public virtual Staff Staff { get; set; }
public String TaskName { get; set; }
}
In my WinForms code I have the following save method:
private void Save()
{
var todo = new ToDo
{
ID = ToDoID,
Staff = ddlStaff.SelectedValue,
Priority = ddlPriority.SelectedValue,
TaskName = txtTaskName.Text.Trim(),
Notes = txtNotes.Text.Trim(),
DueDate = String.IsNullOrEmpty(txtDueDate.Text) ? DateTime.Now : DateTime.Parse(txtDueDate.Text.ToString())
};
_todoController.SaveOrUpdate(todo);
}
The UI has drop down / combo lists for Staff and Priority, but ddlPriority.SelectedValue isn't a Priority object. I could call the database passing the SelectedValue to return the Priority object and then pass that into the ToDo object but that seems crazy just to create/maintain the relationship between the ToDo item and it's priority.