Guest User

Untitled

a guest
Jan 22nd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. @model IndexPageViewModel
  2.  
  3. @{
  4. ViewData["Title"] = "Index";
  5. Layout = "~/Views/Shared/_Layout.cshtml";
  6. }
  7.  
  8. <h2>Index</h2>
  9.  
  10. <p>
  11. <a asp-action="Create">Create New</a>
  12. </p>
  13. <table class="table">
  14. <thead>
  15. <tr>
  16. <th>
  17. Total users: @Model.Users.Count()
  18. </th>
  19. <th></th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. @foreach (var item in Model.Users)
  24. {
  25. string selectedRow = "";
  26. if (item.Id == (int?)Model.UserId)
  27. {
  28. selectedRow = "success";
  29. }
  30. <tr class="@selectedRow">
  31. <td>
  32. @Html.DisplayFor(modelItem => item.Name)
  33. </td>
  34. <td>
  35. <a asp-action="Index" asp-route-id="@item.Id">Load Tasks</a> |
  36. <a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
  37. <a asp-action="Details" asp-route-id="@item.Id">Details</a> |
  38. <a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
  39. </td>
  40. </tr>
  41. }
  42. </tbody>
  43. </table>
  44.  
  45. @if (Model.UserId != null)
  46. {
  47. <h3>Tasks from Selected Users</h3>
  48. <p>
  49. @Html.ActionLink(linkText: "Create Task", actionName: "Create", controllerName: "TaskToDoEntityFramework",
  50. routeValues: new { userId = Model.UserId })
  51. </p>
  52. <table class="table">
  53. <tr>
  54. <th></th>
  55. <th>#</th>
  56. <th>Task</th>
  57. <th>Start</th>
  58. <th>Deadline</th>
  59. <th>Completed</th>
  60. </tr>
  61.  
  62. @foreach (var item in Model.TasksFromUser)
  63. {
  64. <tr>
  65. <td>
  66. @{
  67. @Html.ActionLink(linkText: "Edit", actionName: "Edit", controllerName: "TaskToDo",
  68. routeValues: new { userId = item.UserId, id = item.Id })
  69. <span>|</span>
  70. @Html.ActionLink(linkText: "Delete", actionName: "Delete", controllerName: "TaskToDo",
  71. routeValues: new { userId = item.UserId, id = item.Id })
  72. }
  73. </td>
  74. <td>
  75. @item.Id
  76. </td>
  77. <td>
  78. @item.Title
  79. </td>
  80. <td>
  81. @item.Start
  82. </td>
  83. <td>
  84. @item.DeadLine
  85. </td>
  86. <td>
  87. @{
  88. if (!item.Status)
  89. {
  90. <form asp-action="Complete" asp-controller="TaskToDo">
  91. <input type="hidden" name="Id" value="@item.Id" />
  92. <input type="hidden" name="UserId" value="@item.UserId" />
  93. <input type="submit" value="Complete" class="btn btn-default" />
  94. </form>
  95. }
  96. else
  97. {
  98. <span>Done</span>
  99. }
  100. }
  101. </td>
  102. </tr>
  103. }
  104. </table>
  105. }
Add Comment
Please, Sign In to add comment