@model WebApplication1.Models.news

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm("Create", "news", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()

    <div class="form">
        <h4>news</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

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

        <div class="form-group">
            @Html.LabelFor(model => model.link, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.link, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.link, "", 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.EditorFor(model => model.image, new { htmlAttributes = new { @type = "file", @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.image, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">category</label>
            <div>
                <select id="cat" name="Cat" class="form-control" multiple>
                    @foreach (var item in ViewBag.categoryTitle)
                    {
                        <option value="@item.title">@item.title</option>
                    }
                </select>
                @Html.ValidationMessageFor(model => model.cat, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.tag, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <select id="tag" name="Tags" class="form-control" multiple>
                    @foreach (var item in ViewBag.tagTitle)
                    {
                        <option value="@item.title">@item.title</option>
                    }
                </select>
                @Html.ValidationMessageFor(model => model.tag, "", new { @class = "text-danger" })
            </div>
        </div>

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

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-outline-dark" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
