Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a asp-action="create" asp-controller="instrument" asp-route-
- id="@orchestra.Id" asp-route-musicianId="@Model.Id"> Create an
- instrument</a>
- public IActionResult Details([Bind(Prefix = "id")] int musicianId)
- {
- var musician = _repo.ReadMusician(musicianId);
- if(musician == null)
- {
- return RedirectToAction("Details", "Orchestra", new { id =
- musicianId});
- }
- ViewData["Musician"] = musician;
- return View(musician);
- }
- @using OrchestraManagement.DbFirstData
- @model Musician
- @{
- var orchestra = (Orchestra)ViewData["Orchestra"];
- //var musician = (Musician) ViewData["Musician"];
- ViewData["Title"] = "Details";
- }
- <h2>Details</h2>
- <div>
- <input asp-for="Id" type="hidden" value="@Model.Id"/>
- @*<input name="orchestraId" value="@orchestra.Id" type="hidden"/>*@
- @*<input name="musicianId" value="@musician.Id" type="hidden"/>*@
- <h4>Musician</h4>
- <hr />
- <dl class="dl-horizontal">
- <dt>
- @Html.DisplayNameFor(model => model.Id)
- </dt>
- <dd>
- @Html.DisplayFor(model => model.Id)
- </dd>
- <dt>
- @Html.DisplayNameFor(model => model.FirstName)
- </dt>
- <dd>
- @Html.DisplayFor(model => model.FirstName)
- </dd>
- <dt>
- @Html.DisplayNameFor(model => model.LastName)
- </dt>
- <dd>
- @Html.DisplayFor(model => model.LastName)
- </dd>
- <dt>
- @Html.DisplayNameFor(model => model.Section)
- </dt>
- <dd>
- @Html.DisplayFor(model => model.Section)
- </dd>
- <dt>
- @Html.DisplayNameFor(model => model.SectionLeader)
- </dt>
- <dd>
- @Html.DisplayFor(model => model.SectionLeader)
- </dd>
- <dt>
- Number of instruments:
- </dt>
- <dd>
- @Html.DisplayFor(model => model.Instrument.Count)
- </dd>
- </dl>
- <hr/>
- <h1> Instruments For This Musician:</h1>
- <table class="table">
- <thead>
- <tr>
- <th>
- Serial Number
- </th>
- <th>
- Description
- </th>
- <th>
- Maintenance Date
- </th>
- <th>
- Condition
- </th>
- <th>
- Links:
- </th>
- </tr>
- </thead>
- </table>
- <tbody>
- @foreach(var item in Model.Instrument)
- {
- <tr>
- <td> @Html.DisplayFor(modelItem => item.SerialNumber) </td>
- <td> @Html.DisplayFor(modelItem => item.Description)</td>
- <td> @Html.DisplayFor(modelItem => item.MaintenanceDate)</td>
- <td> @Html.DisplayFor(modelItem => item.Condition))</td>
- <td>
- <a asp-action="edit" asp-controller="instrument" asp-route-id="@Model.Id" asp-route-instrumentId="@item.Id">Details</a>
- <a asp-action="delete" asp-controller="instrument" asp-route-id="@Model.Id" asp-route-instrumentId="@item.Id">Delete</a>
- </td>
- </tr>
- }
- </tbody>
- </table>
- </div>
- <div>
- <a asp-action="create" asp-controller="instrument" asp-route-id="@orchestra.Id" asp-route-musicianId="@Model.Id"> Create an instrument</a> |
- @*<a asp-action="Create" asp-controller="Musician" asp-route-id="@Model.Id"> Create a musician</a> |*@
- <a asp-action="edit" asp-controller="musician" asp-route-id="@Model.Id"> Edit this musician</a>|
- <a asp-action="details" asp-controller="orchestra" asp-route-id="@orchestra.Id">Back to Orchestra Details</a>
- </div>
- public Musician ReadMusician(int musicianId)
- {
- return _db.Musician.Include(m => m.Instrument).FirstOrDefault(m => m.Id
- == musicianId);
- }
- var orchestra = (Orchestra)ViewData["Orchestra"];
Add Comment
Please, Sign In to add comment