Advertisement
Guest User

Untitled

a guest
Jan 7th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.EntityFrameworkCore;
  5. using TestIspit.Data.DATA;
  6. using TestIspit.Data.EntityModels;
  7. using TestIspit.Web.ViewModels;
  8.  
  9. namespace TestIspit.Web.Controllers
  10. {
  11. public class OdjeljenjeController : Controller
  12. {
  13. private readonly MyDbContext _context;
  14.  
  15. public OdjeljenjeController(MyDbContext context)
  16. {
  17. _context = context;
  18. }
  19.  
  20. public IActionResult Prikazi()
  21. {
  22.  
  23. List<OdjeljenjePrikaziViewModel> model =
  24. _context.Odjeljenje.Select(od =>
  25. new OdjeljenjePrikaziViewModel
  26. {
  27. Razred = od.Razred,
  28. Oznaka = od.Oznaka,
  29. SkolskaGodina = od.SkolskaGodina,
  30. isPrebacenUViseOdjeljenje = od.isPrebacenUViseOdjeljenje,
  31. Razrednik = od.Razrednik.ImePrezime,
  32. OdjeljenjeId = od.Id,
  33. ProsjekOcjena = _context.DodijeljenPredmets.Where(x => x.OdjeljenjeStavka.OdjeljenjeId == od.Id)
  34. .Average(i => (int?)i.ZakljucnoKrajGodine) ?? 0,
  35.  
  36.  
  37. }).ToList();
  38.  
  39.  
  40. return View(model);
  41. }
  42. }
  43. }
  44.  
  45. ------------------------------------------------------------------------------------
  46.  
  47.  
  48. @using TestIspit.Web.ViewModels
  49. @model List<OdjeljenjePrikaziViewModel>
  50. @{
  51. ViewData["Title"] = "Prikazi";
  52. }
  53.  
  54. <h2>Prikazi</h2>
  55. <hr />
  56.  
  57. <table class="table text-center">
  58. <thead class="thead-light">
  59. <tr>
  60. <th>Školska<br />godina</th>
  61. <th>Razred<br />(1 do 4)</th>
  62. <th>Oznaka</th>
  63. <th>Razrednik</th>
  64. <th>Prebačeni u viši<br />razred<br />(odjeljenje)</th>
  65. <th>Prosječna<br />ocjena</th>
  66. <th>Akcija</th>
  67. </tr>
  68. </thead>
  69. <tbody>
  70. @foreach (var od in Model)
  71. {
  72. <tr>
  73. <td>@od.SkolskaGodina</td>
  74. <td>@od.Razred</td>
  75. <td>@od.Oznaka</td>
  76. <td>@od.Razrednik</td>
  77. <td>@(od.isPrebacenUViseOdjeljenje ? "Da" : "Ne")</td>
  78. <td>@od.ProsjekOcjena.ToString($"F{2}")</td>
  79. <td>
  80. <a asp-action="Detalji" asp-route-id="@od.OdjeljenjeId" class="btn btn-info">Detalji</a>
  81. <a asp-action="Obrisi" asp-route-id="@od.OdjeljenjeId" class="btn btn-danger">Obrisi</a>
  82. </td>
  83. </tr>
  84. }
  85. </tbody>
  86. </table>
  87. <a asp-action="Dodaj" class="btn btn-primary">Dodaj</a>
  88. <a asp-action="Index" asp-controller="Home" class="float-right btn-light">Nazad</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement