This is my interface
interface IBase
{
string MvrId { get; set; }
string IndividualFullName { get; set; }
string FirstHospitalCaseNumber { get; set; }
}
I have a class
public class AddMedicineModel:IBase
{
private MedicalVarianceEntities DbCtx = new MedicalVarianceEntities();
public AddMedicineModel(int MvrId)
{
Mvr Mvr = DbCtx.Mvrs.Find(MvrId);
this.MvrId = Mvr.PKMvrId.ToString();//for display purposes
IndividualFullName = Mvr.IndividualLastName
+ ", "
+ Mvr.IndividualFirstName;
FirstHospitalCaseNumber = Mvr.CaseNumber.ToString();
}
//IBASE INTERFACE IMPLEMENTATION
public string MvrId { get; set; }
public string IndividualFullName { get; set; }
public string FirstHospitalCaseNumber { get; set; }
}
Here is my partial view! NOTICE THAT MY Partial view is not attached to my AddMedicineModel
Therefore, I cant re-use it with other models that inherit from IBase.How can I make a re-usable partial view for many models.
@model MedicalVariance.Models.ViewModels.AddMedicineModel
@Html.DisplayFor(model => model.MvrId)
@Html.DisplayFor(model => model.IndividualFullName)
@Html.DisplayFor(model => model.FirstHospitalCaseNumber)
Just declare it as taking the interface: