Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. @model IEnumerable<testwoon.Models.Product>
  2. @using testwoon.Models;
  3. @{
  4. ViewBag.Title = "List";
  5. }
  6.  
  7. <table class="table">
  8. <tr>
  9. <th>
  10. @Html.DisplayNameFor(model => model.NameProduct)
  11. </th>
  12. <th>
  13. @Html.DisplayNameFor(model => model.DescriptionProduct)
  14. </th>
  15. <th>
  16. @Html.DisplayNameFor(model => model.PictureProduct)
  17. </th>
  18. <th>
  19. @Html.DisplayNameFor(model => model.DateProduct)
  20. </th>
  21. </tr>
  22.  
  23. @foreach (Product item in Model)
  24. {
  25. <tr>
  26. <td>
  27. <a href="@Url.Action("Redict", "Product", new { id = item.Id })"> @Html.DisplayFor(modelItem => item.NameProduct)"</a>
  28. </td>
  29. <td>
  30. @Html.DisplayFor(modelItem => item.DescriptionProduct)
  31. </td>
  32. <td>
  33. @*В ЭТУ СТРОКУ НЕ ПОПАДАЕТ КОМПИЛЯТОР*@ <img width="150" height="150" src="@Url.Action("GetImage", "Product", new { productId = item.Id })" />
  34. </td>
  35. <td>
  36. @Html.DisplayFor(modelItem => item.DateProduct)
  37. </td>
  38. </tr>
  39. }
  40.  
  41. </table>
  42.  
  43. public FileContentResult GetImage(int productId)
  44. {
  45. PictureProduct image = db.PictureProduct.FirstOrDefault(p => p.IdProduct == productId);
  46. if (image != null)
  47. {
  48. return File(image.Picture, "image/jpg");
  49. }
  50. else
  51. {
  52. return null;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement