﻿@model BlogSystem.Web.ViewModels.Comment.CommentViewModel

<h3>Leave a Comment</h3>

@if (User.Identity.IsAuthenticated)
{
    using (Ajax.BeginForm("Create", "Comments", new { id = ViewData["id"].ToString() }, new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "comments", OnFailure = "BlogSystem.onCreateCommentFailure" }))
    {
        @Html.AntiForgeryToken()

        @Html.ValidationSummary(true, string.Empty, new { @class = "text-danger" })
        @Html.HiddenFor(model => model.Id)

        <div class="form-group">
            @Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control " } })
            @Html.ValidationMessageFor(model => model.Content, string.Empty, new { @class = "text-danger" })
        </div>

        <button type="submit" class="btn btn-default">Add Comment</button>
    }
}
else
{
    <p>Only registered users can comment.</p>
}
﻿@model BlogSystem.Web.ViewModels.Comment.CommentViewModel

<h3>Leave a Comment</h3>

@if (User.Identity.IsAuthenticated)
{
    using (Ajax.BeginForm("Create", "Comments", new { id = ViewData["id"].ToString() }, new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "comments", OnFailure = "BlogSystem.onCreateCommentFailure", OnSuccess = "BlogSystem.onAddCommentSuccess" }))
    {
        @Html.AntiForgeryToken()

        @Html.ValidationSummary(true, string.Empty, new { @class = "text-danger" })
        @Html.HiddenFor(model => model.Id)

        <div class="form-group">
            @Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control " } })
            @Html.ValidationMessageFor(model => model.Content, string.Empty, new { @class = "text-danger" })
        </div>

        <button type="submit" class="btn btn-default">Add Comment</button>
    }
}
else
{
    <p>Only registered users can comment.</p>
}
Update Create Comment Ajax Form
Update Create Comment Ajax Form
