<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Page.Master" Inherits="System.Web.Mvc.ViewPage<MVCBlogo.NET.BO.BlogEntry>" %>
<%@ Import Namespace="MVCBlogo.NET.BO" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderPage" runat="server">

<div class="post">
      <div class="header">
        <h3><% =Html.ActionLink(Model.title, "BlogEntry", new{ page = Model.id  } ) %></h3><!--博客文章名称-->
        <div class="date"><% =Model.datecreated%></div><!--博客文章的创建时间-->
      </div>

  <div class="content">
        
        <% =Model.body%>
        <p><strong><% =Model.author.username%></strong></p> <!--博客的作者-->
        </div>
        <div class="footer">
        <ul>
        <li class="tags">分类：  
           <% foreach (var tag in Model.tags)  
              { %>
           <% =Html.ActionLink(tag.tagname, "BlogEntry", new { id = ViewData.Model.id })%>
           <% } %>        
        
        </li>


		<li class="comments"> 
            <% =(bool)ViewData.Model.allowcomments ? "<a href=\"BlogEntry.aspx?page=" + ViewData.Model.id + "#comments\">评论(" + ViewData.Model.comments.Count + ")</a>" : "- disabled -"%></li>
        </ul>
        </div>
        </div>

     
<% if( ViewData.Model.comments.Count > 0 ){ %>  <!--显示这个博客的评论-->
<% foreach( var comment in ViewData.Model.comments ){ %>
    
  <h4>  <a name="comments">&#35780;&#35770;</a></h4>
     
        <div class="post">
        <div class="content">
        <p>

 <%=comment.body   %>
        </p>
        </div>
        <div class="footer">
        <ul>
        <li class="comment">Comment by <strong><%=comment.author %></strong></li>
        </ul>
        <div class="date"><%=string.Format( "{0: yyyy年mmmm月dd日 hh:mm}",comment.datecreated)%></div>
        </div>
        </div>


<% } %>

<% }else{ %>

  <div class="post">
        <div class="header">
        <a name="comments"><h3>还没有评论!</h3></a>
        </div>
        </div>

<% } %>
<%using (Html.BeginForm())
  { %>
  <%=Html.ValidationSummary() %>
<fieldset>
   <legend>发表评论</legend>
   <table style="width:100%">
      <tr valign="top">
        <td width="100">
         <strong>您的名字：</strong>
        </td>
        <td>
           <%=Html.ValidationMessage("commentAuthor", "*")%>
           <%=Html.TextBox("commentAuthor")%>
        </td>
      </tr>

      <tr valign="top">
        <td width="100">
         <strong>评论</strong>
        </td>
        <td>
           <%=Html.ValidationMessage("commentText", "*")%>
           <%=Html.TextArea("commentText", "", 10, 60, 1)%>
        </td>
      </tr>

      <tr valign="top">
        <td >
         &nsbp;
        </td>
        <td>
        
           <input type="submit" value="发表新评论" />
        </td>
      </tr>
   </table>
</fieldset>
<%} %>
</asp:Content>
