@model MVC121.Areas.Administrator.Models.Post

@{
    ViewBag.Title = "ویرایش مطلب";
    Layout = "~/Areas/Administrator/Views/Shared/_Layout.cshtml";
}

@section styles{
    <link href="~/Scripts/TagsInput/bootstrap-tagsinput.css" rel="stylesheet" />
    <link href="~/Content/jquery-ui-datetimepicker.min.css" rel="stylesheet" />
    <link href="~/Theme/redmond/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" />
}

<hr />

<img src="~/Areas/Administrator/img/writing_s.png" alt="category" />

<h2>ویرایش</h2>


@using (Html.BeginForm("Edit", "Posts", FormMethod.Post, new { enctype = "multipart/form-data", id = "myUploadForm" }))
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>@Model.Name</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ID)

        <div class="form-group">
            @Html.LabelFor(model => model.PostCategoryID, "کاربر ارشد", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("AdminID", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.AdminID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PostCategoryID, "دسته بندی مطالب", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("PostCategoryID", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.PostCategoryID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PoetryWriter, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.PoetryWriter, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.PoetryWriter, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.SmallBody, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.SmallBody, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.SmallBody, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.FullBody, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextAreaFor(model => model.FullBody, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.FullBody, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Keyword, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Keyword, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Keyword, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PublishTime, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.PublishTime, new { htmlAttributes = new { @class = "form-control", ID = "txtDate" } })
                @Html.ValidationMessageFor(model => model.PublishTime, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.IsActive, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.EditorFor(model => model.IsActive)
                    @Html.ValidationMessageFor(model => model.IsActive, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.IsCommentable, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.EditorFor(model => model.IsCommentable)
                    @Html.ValidationMessageFor(model => model.IsCommentable, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Image, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Image, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Image, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Image, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.Upload("UploadImage")
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <button class="btn btn-primary">ویرایش مطلب</button>
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("بازگشت به صفحه مدیریت مطالب", "Index", "Posts")
</div>



@section scripts{
<script src="~/Scripts/TagsInput/bootstrap-tagsinput.min.js"></script>
    <script>
        $(function () {
            $("#Keyword").keypress(function (event) {
                if (event.keyCode == 13) {
                    event.preventDefault();
                }
            }).tagsinput();
        });

    </script>

    <script src="~/Scripts/tinymce/tiny_mce.js" type="text/javascript"></script>

    <script src="~/Scripts/tinymce/tinymce.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        tinymce.init({
            selector: "textarea",
            theme: "modern",
            plugins: [
                "advlist autolink lists link image charmap print preview hr anchor pagebreak",
                "searchreplace wordcount visualblocks visualchars code fullscreen",
                "insertdatetime media nonbreaking save table contextmenu directionality",
            ],
            toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image |print preview media | forecolor backcolor emoticons ",
            toolbar2: "",
            image_advtab: true,
            templates: [
                { title: 'Test template 1', content: 'Test 1' },
                { title: 'Test template 2', content: 'Test 2' }
            ],
            language: "fa_IR"
        });
    </script>

    <script src="~/Scripts/jquery-ui-datetimepicker.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#txtDate").datepicker({
                showButtonPanel: true,
                changeMonth: true,
                changeYear: true,
                changeTime:true
            });
        });
    </script>
}
