displaying blog comments

main
Paul Schneider 8 years ago
parent bfa0aaa741
commit 3487aa2a96
9 changed files with 53 additions and 10 deletions

@ -1,6 +1,8 @@
using System.Linq;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Yavsc.Helpers; using Yavsc.Helpers;
using Yavsc.Models; using Yavsc.Models;
using Yavsc.ViewModels.Account;
namespace Yavsc.ViewComponents namespace Yavsc.ViewComponents
{ {
@ -14,7 +16,14 @@ namespace Yavsc.ViewComponents
public IViewComponentResult Invoke ( string userId, string imgFmt ) public IViewComponentResult Invoke ( string userId, string imgFmt )
{ {
return View ( "Default", dbContext.AvatarUri(userId, imgFmt)); var user = dbContext.Users.Single(u=>u.Id == userId);
return View ( "Default", new ShortUserInfo
{
Avatar = dbContext.AvatarUri(userId, imgFmt),
UserName = user.UserName,
UserId = userId
} );
} }
} }

@ -0,0 +1,11 @@
namespace Yavsc.ViewModels.Account
{
public class ShortUserInfo
{
public string Avatar { get; set; }
public string UserName { get; set; }
public string UserId { get; set; }
}
}

@ -71,10 +71,17 @@ $('span.field-validation-valid[data-valmsg-for="Content"]').html(
@Component.Invoke("Tagger",Model) @Component.Invoke("Tagger",Model)
</div> </div>
@if (Model.Comments.Count>0) {
<div class="comments"> <div class="comments">
@foreach (Comment comment in Model.Comments) { @foreach (Comment comment in Model.Comments) {
<div markdown="@comment.Content" class="blogcomment"> <div class="blogcomment" >
<div class="commentmeta" style="display: inline-block">
@Html.DisplayFor(c=>c.Author,"ApplicationUserLink","cmtauth",comment)
<div><i>@Html.DisplayFor(c=>c.DateCreated,null,"dteCmt",comment)</i></div>
</div>
<div markdown="@comment.Content" style="display: inline-block;">
</div>
</div> </div>
} }
@ -93,6 +100,7 @@ $('span.field-validation-valid[data-valmsg-for="Content"]').html(
</div> </div>
</form> </form>
</div> </div>
}
</div> </div>
@if (await AuthorizationService.AuthorizeAsync(User, Model, new EditRequirement())) { @if (await AuthorizationService.AuthorizeAsync(User, Model, new EditRequirement())) {
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-link">@SR["Edit"]</a> <a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-link">@SR["Edit"]</a>

@ -1,2 +1,5 @@
@model string @model ShortUserInfo
<img src="@Model" alt="" /> <div style="display: inline-block;">
<img src="@Model.Avatar" alt="@Model.UserName" class="smalltofhol" />
<div >@Model.UserName</div>
</div>

@ -2,8 +2,7 @@
@if (Model!=null) { @if (Model!=null) {
<div class="userinfo"> <div class="userinfo">
<h3>@Component.Invoke("Avatar", Model.Id, ".s") <h3>@Component.Invoke("Avatar", Model.Id, ".s")</h3>
@Model.UserName </h3>
@if (Model.Posts!=null && Model.Posts.Count()>1) { <a asp-controller="Blogspot" asp-action="UserPosts" @if (Model.Posts!=null && Model.Posts.Count()>1) { <a asp-controller="Blogspot" asp-action="UserPosts"
asp-route-id="@Model.UserName" class="btn btn-primary">@SR["index de ses articles"]</a> asp-route-id="@Model.UserName" class="btn btn-primary">@SR["index de ses articles"]</a>
} }

@ -0,0 +1,5 @@
@model ApplicationUser
@if (Model!=null) {
@Component.Invoke("Avatar", Model.Id, ".xs")
}

@ -7,7 +7,7 @@
<li> <li>
<a asp-controller="Manage" class="navbar-link" asp-action="Index" title="Manage"> <a asp-controller="Manage" class="navbar-link" asp-action="Index" title="Manage">
@Component.Invoke("Avatar", User.GetUserId(), ".xs") @Component.Invoke("Avatar", User.GetUserId(), ".xs")
@SR["Hello"] @User.GetUserName()!</a> </a>
</li> </li>
@if (User.IsInRole(Constants.AdminGroupName)) { @if (User.IsInRole(Constants.AdminGroupName)) {
<li class="dropdown"> <li class="dropdown">

@ -50,7 +50,15 @@
.smalltofhol { .smalltofhol {
align-self: left; align-self: left;
padding: 1em; padding: .5em;
border-radius: 32px;
}
.commentmeta {
margin: .5em;
padding: .5em;
border-right: #444 dashed 1px;
border-top: #444 solid 1px;
} }
.price { .price {

@ -1 +1 @@
var notifClick=function(i){i>0&&$.get("/api/dimiss/click/"+i).done(function(){}).fail(function(){}).always(function(){})},setUiCult=function(i){document.cookie="ASPNET_CULTURE=c="+i+"|uic="+i,location.reload()}; var notifClick=function(i){i>0&&$.get("/api/dimiss/click/"+i)},setUiCult=function(i){document.cookie="ASPNET_CULTURE=c="+i+"|uic="+i,location.reload()};
Loading…