Ajout de la page de détail
This commit is contained in:
parent
4954c68161
commit
f15443be34
@ -50,6 +50,16 @@ namespace Application
|
|||||||
// CommentsCount = 54,
|
// CommentsCount = 54,
|
||||||
// }).ToArray();
|
// }).ToArray();
|
||||||
|
|
||||||
|
return LinksDTO().ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkDTO GetLinkById(Guid id)
|
||||||
|
{
|
||||||
|
return LinksDTO().Single(link => link.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IQueryable<LinkDTO> LinksDTO()
|
||||||
|
{
|
||||||
return _data.Links
|
return _data.Links
|
||||||
.Select(link => new LinkDTO
|
.Select(link => new LinkDTO
|
||||||
{
|
{
|
||||||
@ -61,8 +71,7 @@ namespace Application
|
|||||||
CommentsCount = 54,
|
CommentsCount = 54,
|
||||||
})
|
})
|
||||||
// .Where(linkDto => linkDto.UpvotesCount > 5)
|
// .Where(linkDto => linkDto.UpvotesCount > 5)
|
||||||
.OrderByDescending(linkDto => linkDto.CreatedAt)
|
.OrderByDescending(linkDto => linkDto.CreatedAt);
|
||||||
.ToArray();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using Application;
|
using Application;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -18,6 +19,12 @@ namespace Website
|
|||||||
return View(_service.GetAllLinks());
|
return View(_service.GetAllLinks());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("{controller}/detail/{linkId:guid}")]
|
||||||
|
public IActionResult Show(Guid linkId)
|
||||||
|
{
|
||||||
|
return View(_service.GetLinkById(linkId));
|
||||||
|
}
|
||||||
|
|
||||||
// [HttpGet] // Implicite car HttpGet par défaut
|
// [HttpGet] // Implicite car HttpGet par défaut
|
||||||
public IActionResult Create()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
@foreach (var link in Model)
|
@foreach (var link in Model)
|
||||||
{
|
{
|
||||||
<li>@link.Url - @link.CreatedAt</li>
|
<li>@link.Url - @link.CreatedAt - 🗨 @link.CommentsCount - <a asp-controller="Links" asp-action="Show" asp-route-linkId="@link.Id">Show</a></li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
}
|
}
|
||||||
6
Apps/Website/Views/Links/Show.cshtml
Normal file
6
Apps/Website/Views/Links/Show.cshtml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@model Application.LinkDTO
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = $"Viewing link {Model.Url}";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1>Viewing link @Model.Url</h1>
|
||||||
Loading…
x
Reference in New Issue
Block a user