I ve added a drop down into my shared adminheader.cshtl view and it needs to be dynamically updated from data from a table. So when I use another view like routeplan.cshtml I load the view from routeplancontroller which uses routeplanmodel. It would follow that I need a controller for adminheader.cshtml which would then get confusing. What would be the best way to update the adminheadermodel.cs and subsequently the adminheader.cshtml from routeplancontroller in addition to loading routeplanmodel?
This is the model for adminheader
public class AdminHeaderModel
{
public string UserId { get; set; } = null!;
public string Domain { get; set; } = null!;
public string Link_Type { get; set; } = null!;
public string Icon { get; set; } = null!;
}
This is the code to load to drop down in adminheader.cshtml
@foreach (AdminHeaderModel hdr in Model)
{
<div class="dropdown-item light-box-container account selected" rel=".com" data-id=@hdr.DataId>
<div class="account-info">
<img src=@hdr.Icon>
<span class="account-name">@hdr.Domain</span>
</div>
<div class="account-actions">
if (hdr.Link_Type == "0")
{
<div class="account-status pass">Connected</div>
<div class="account-select"><i class="fas fa-check-circle"></i></div>
}
else
{
<div class="account-status warn"><i class="fas fa-exclamation"></i>Connect</div>
<div class="account-select"><i class="far fa-check-circle"></i></div>
}
</div>
</div>
}
Could someone please help me figure out the easiest way to load my adminheadermodel from my routeplancontroller or if I need an adminheadercontroller, how to implement it.