I am VERY new to MVC.
I am using .NET core 2.0 with EntityFrameworkCore. I have my contexts established and data, models, controllers, views all working at the most basic level.
I have model/view/controller for HRIS
data and model/view/controller for Entity
(not Entity Framework) data (among others).
Entity
model contains company
, division
, location
, contract
, etc.
On the HRIS
view Index.cshtml
page I need to pull all entities that are of type contract
and populate a <select>
which will then determine which contract
the HRIS data is related to. Example: User sees contract select and picks Contract1. All future actions in this view will reference HRIS data associated with Contract1.
Basic flow scheme:
- User enters New Contract in
Entity
View. - User goes to
HRIS
view and selects Contract from Select. - User imports
HRIS
data from text file that will be associated with that Contract. - User proceeds to view/model/controller to edit imported
HRIS
data.
I realize that my code must handle the actual import and associating the data with the contract. I'm just trying to find out how to populate the <select>
within the confines of MVC while the Contract
data is in the Entity
model and not in the HRIS
model.
I've allowed the framework to create <select>
controls for other items in the application using:
<select asp-for="EntityTypeID" class="form-control" asp-items="ViewBag.EntityTypeID"></select>
and
ViewData["EntityTypeID"] = new SelectList(_context.EntityTypes, "EntityTypeID", "EntityTypeName");
and this works very well but these are within the same model.
Important note: after data is imported, it will be handled completely by another view/model/controller if that makes any difference in how this is handled.
Any suggestions would be appreciated.