Guest User

Untitled

a guest
Jan 5th, 2019
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. <a asp-action="create" asp-controller="instrument" asp-route-
  2. id="@orchestra.Id" asp-route-musicianId="@Model.Id"> Create an
  3. instrument</a>
  4.  
  5. public IActionResult Details([Bind(Prefix = "id")] int musicianId)
  6. {
  7. var musician = _repo.ReadMusician(musicianId);
  8. if(musician == null)
  9. {
  10. return RedirectToAction("Details", "Orchestra", new { id =
  11. musicianId});
  12. }
  13.  
  14. ViewData["Musician"] = musician;
  15. return View(musician);
  16. }
  17.  
  18. @using OrchestraManagement.DbFirstData
  19. @model Musician
  20.  
  21. @{
  22. var orchestra = (Orchestra)ViewData["Orchestra"];
  23. //var musician = (Musician) ViewData["Musician"];
  24. ViewData["Title"] = "Details";
  25. }
  26.  
  27. <h2>Details</h2>
  28. <div>
  29. <input asp-for="Id" type="hidden" value="@Model.Id"/>
  30. @*<input name="orchestraId" value="@orchestra.Id" type="hidden"/>*@
  31. @*<input name="musicianId" value="@musician.Id" type="hidden"/>*@
  32. <h4>Musician</h4>
  33. <hr />
  34. <dl class="dl-horizontal">
  35. <dt>
  36. @Html.DisplayNameFor(model => model.Id)
  37. </dt>
  38. <dd>
  39. @Html.DisplayFor(model => model.Id)
  40. </dd>
  41. <dt>
  42. @Html.DisplayNameFor(model => model.FirstName)
  43. </dt>
  44. <dd>
  45. @Html.DisplayFor(model => model.FirstName)
  46. </dd>
  47. <dt>
  48. @Html.DisplayNameFor(model => model.LastName)
  49. </dt>
  50. <dd>
  51. @Html.DisplayFor(model => model.LastName)
  52. </dd>
  53. <dt>
  54. @Html.DisplayNameFor(model => model.Section)
  55. </dt>
  56. <dd>
  57. @Html.DisplayFor(model => model.Section)
  58. </dd>
  59. <dt>
  60. @Html.DisplayNameFor(model => model.SectionLeader)
  61. </dt>
  62. <dd>
  63. @Html.DisplayFor(model => model.SectionLeader)
  64. </dd>
  65. <dt>
  66. Number of instruments:
  67. </dt>
  68. <dd>
  69. @Html.DisplayFor(model => model.Instrument.Count)
  70. </dd>
  71. </dl>
  72. <hr/>
  73. <h1> Instruments For This Musician:</h1>
  74. <table class="table">
  75. <thead>
  76. <tr>
  77. <th>
  78. Serial Number
  79. </th>
  80. <th>
  81. Description
  82. </th>
  83. <th>
  84. Maintenance Date
  85. </th>
  86. <th>
  87. Condition
  88. </th>
  89. <th>
  90. Links:
  91. </th>
  92. </tr>
  93. </thead>
  94. </table>
  95. <tbody>
  96. @foreach(var item in Model.Instrument)
  97. {
  98. <tr>
  99. <td> @Html.DisplayFor(modelItem => item.SerialNumber) </td>
  100. <td> @Html.DisplayFor(modelItem => item.Description)</td>
  101. <td> @Html.DisplayFor(modelItem => item.MaintenanceDate)</td>
  102. <td> @Html.DisplayFor(modelItem => item.Condition))</td>
  103. <td>
  104. <a asp-action="edit" asp-controller="instrument" asp-route-id="@Model.Id" asp-route-instrumentId="@item.Id">Details</a>
  105. <a asp-action="delete" asp-controller="instrument" asp-route-id="@Model.Id" asp-route-instrumentId="@item.Id">Delete</a>
  106. </td>
  107. </tr>
  108. }
  109. </tbody>
  110. </table>
  111. </div>
  112.  
  113. <div>
  114. <a asp-action="create" asp-controller="instrument" asp-route-id="@orchestra.Id" asp-route-musicianId="@Model.Id"> Create an instrument</a> |
  115. @*<a asp-action="Create" asp-controller="Musician" asp-route-id="@Model.Id"> Create a musician</a> |*@
  116. <a asp-action="edit" asp-controller="musician" asp-route-id="@Model.Id"> Edit this musician</a>|
  117. <a asp-action="details" asp-controller="orchestra" asp-route-id="@orchestra.Id">Back to Orchestra Details</a>
  118. </div>
  119.  
  120. public Musician ReadMusician(int musicianId)
  121. {
  122. return _db.Musician.Include(m => m.Instrument).FirstOrDefault(m => m.Id
  123. == musicianId);
  124. }
  125.  
  126. var orchestra = (Orchestra)ViewData["Orchestra"];
Add Comment
Please, Sign In to add comment