I have 2 Models. First one is created by EF and looks like:
public partial class PrinterMapping
{
public string MTPrinterID { get; set; }
public string NTPrinterID { get; set; }
public string Active { get; set; }
}
I created the second one (nothing to do with any database table) and looks like:
public class ExceptionModel
{
public string ExceptionMessage { get; set; }
public ExceptionModel(string exceptionMessage)
{
ExceptionMessage = exceptionMessage;
}
}
In my Index and Create views, the model that is automatically being passed is PrinterMapping. I wish to output ExceptionMessage property of the ExceptionModel model after populating it in a relevant way after saving to the table accessed by PrinterMapping. So in my Create controller, I am doing:
ExceptionModel exModel = new ExceptionModel(message);
where message parameter is a relevant string like "Printer X already exists".
My thoughts were to have a partial view called ExceptionMessageView where my ExceptionModel would be passed on to it and I will display:
@Html.DisplayFor(model => model.ExceptionMessage)
And in my Index and Create views, I will have a line like:
@Html.Partial("~/Views/Home/ExceptionMessageView.cshtml")
Am I over complicating things? This isn't working anyway since I don't fully understand how to pass on the populated ExceptionModel from my Create Controller to the ExceptionMessageView partial view.
Will a kind soul please enlighten?