summaryrefslogtreecommitdiff
path: root/Project-Unite/Views/Blog/ViewBlog.cshtml
blob: 05116984a349f7e489776a244b9b96dc30a5b4db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@model Project_Unite.Models.BlogPost
@{
    ViewBag.Title = Model.Name;
}

<h2>Developer Blog</h2>

<h3>@Model.Name</h3>

@if (!string.IsNullOrWhiteSpace(ViewBag.Error))
{
    <div class="panel panel-danger">
        <div class="panel-body">
            <p><span class="glyphicon glyphicon-exclamation-sign"></span> @ViewBag.Error</p>
        </div>
    </div>
}

<p>Posted by @Html.UserLink(Model.AuthorId) at @Model.PostedAt</p>

<div class="panel">
    <div class="panel-body">
        @Html.Markdown(Model.Contents)
    </div>
</div>

<ul class="nav nav-pills">
    @{ 
        string like_uri = "#";
        string dislike_uri = "#";

        if (Request.IsAuthenticated)
        {
            like_uri = Url.Action("LikePost", new { id = Model.Id });
            dislike_uri = Url.Action("DislikePost", new { id = Model.Id });
        }

        <li><a href="@like_uri"><span class="glyphicon glyphicon-thumbs-up"></span> @Model.Likes.Length</a></li>
        <li><a href="@dislike_uri"><span class="glyphicon glyphicon-thumbs-down"></span> @Model.Dislikes.Length</a></li>
    }
</ul>

<hr/>

<h4>Comments</h4>

@if (Request.IsAuthenticated)
{
    <div class="panel">
        <div class="panel-body">
            @using (Html.BeginForm())
            {
                <input type="hidden" name="id" value="@Model.Id" />
                @Html.AntiForgeryToken()

                <textarea class="form-control" rows="5" name="comment" value=""></textarea>
                <input type="submit" class="btn btn-primary" value="Comment" />
            }
        </div>
    </div>
}

@foreach(var comment in Model.Comments.OrderBy(x=>x.PostedAt))
{
    <div class="panel">
        <div class="panel-body">
            <p><strong>@Html.UserLink(comment.AuthorId)</strong> said on @comment.PostedAt:</p>
            <p>@Html.Markdown(comment.Body)</p>
        </div>
    </div>
}