Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model IEnumerable<testwoon.Models.Product>
- @using testwoon.Models;
- @{
- ViewBag.Title = "List";
- }
- <table class="table">
- <tr>
- <th>
- @Html.DisplayNameFor(model => model.NameProduct)
- </th>
- <th>
- @Html.DisplayNameFor(model => model.DescriptionProduct)
- </th>
- <th>
- @Html.DisplayNameFor(model => model.PictureProduct)
- </th>
- <th>
- @Html.DisplayNameFor(model => model.DateProduct)
- </th>
- </tr>
- @foreach (Product item in Model)
- {
- <tr>
- <td>
- <a href="@Url.Action("Redict", "Product", new { id = item.Id })"> @Html.DisplayFor(modelItem => item.NameProduct)"</a>
- </td>
- <td>
- @Html.DisplayFor(modelItem => item.DescriptionProduct)
- </td>
- <td>
- @*В ЭТУ СТРОКУ НЕ ПОПАДАЕТ КОМПИЛЯТОР*@ <img width="150" height="150" src="@Url.Action("GetImage", "Product", new { productId = item.Id })" />
- </td>
- <td>
- @Html.DisplayFor(modelItem => item.DateProduct)
- </td>
- </tr>
- }
- </table>
- public FileContentResult GetImage(int productId)
- {
- PictureProduct image = db.PictureProduct.FirstOrDefault(p => p.IdProduct == productId);
- if (image != null)
- {
- return File(image.Picture, "image/jpg");
- }
- else
- {
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement