Ajout de la page de détail
This commit is contained in:
parent
4954c68161
commit
f15443be34
@ -50,6 +50,16 @@ namespace Application
|
||||
// CommentsCount = 54,
|
||||
// }).ToArray();
|
||||
|
||||
return LinksDTO().ToArray();
|
||||
}
|
||||
|
||||
public LinkDTO GetLinkById(Guid id)
|
||||
{
|
||||
return LinksDTO().Single(link => link.Id == id);
|
||||
}
|
||||
|
||||
private IQueryable<LinkDTO> LinksDTO()
|
||||
{
|
||||
return _data.Links
|
||||
.Select(link => new LinkDTO
|
||||
{
|
||||
@ -61,8 +71,7 @@ namespace Application
|
||||
CommentsCount = 54,
|
||||
})
|
||||
// .Where(linkDto => linkDto.UpvotesCount > 5)
|
||||
.OrderByDescending(linkDto => linkDto.CreatedAt)
|
||||
.ToArray();
|
||||
.OrderByDescending(linkDto => linkDto.CreatedAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Application;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@ -18,6 +19,12 @@ namespace Website
|
||||
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
|
||||
public IActionResult Create()
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<ul>
|
||||
@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>
|
||||
}
|
||||
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