@using ZelWiki.Models
@model ZelWiki.Models.ViewModels.Admin.EmojiViewModel
@{
    Layout = "/Views/Shared/_Layout.cshtml";
    var sessionState = ViewData["SessionState"] as ZelWiki.SessionState ?? throw new Exception("Wiki State Context cannot be null.");
}

<h3>Emoji</h3>
<p>
    <br /><br />
</p>


@if (!string.IsNullOrEmpty(Model.ErrorMessage))
{
    <div class="alert alert-danger">@Html.Raw(Model.ErrorMessage)</div>
}
@if (!string.IsNullOrEmpty(Model.SuccessMessage))
{
    <div class="alert alert-success">@Html.Raw(Model.SuccessMessage)</div>
}

@using (Html.BeginForm(null, null, new { navigation = Model.Emoji.Name }, FormMethod.Post, true, new { action = $"{GlobalConfiguration.BasePath}{Context.Request.Path}", enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(m => m.OriginalName)
    @Html.HiddenFor(m => m.Emoji.Id)

    <div class="container">
        <div class="form-group row mb-1">
            <label for="ImageData" class="col-sm-2 col-form-label"><strong>图片</strong></label>
            <div class="col-sm-10">
                @if (@Model.Emoji.Name != "")
                {
                    <img src="@GlobalConfiguration.BasePath/File/Emoji/@Model.Emoji.Name" class="mb-3" />
                    <br />
                }
                <input type="file" id="ImageData" name="ImageData" class="form-control-file" onchange="fileCheck(this);" accept="image/png, image/jpeg, image/gif" />
            </div>
        </div>

        <div class="form-group row mb-1">
            <label for="Name" class="col-sm-2 col-form-label"><strong>@Html.LabelFor(m => m.Emoji.Name)</strong></label>
            <div class="col-sm-10">
                @Html.TextBoxFor(m => m.Emoji.Name, new { @class = "form-control" })
                <div class="text-danger">@Html.ValidationMessageFor(m => m.Emoji.Name)</div>
            </div>
        </div>

        <div class="form-group row mb-1">
            <label for="Categories" class="col-sm-2 col-form-label"><strong>@Html.LabelFor(m => m.Categories)</strong> (以英文逗号分割)</label>
            <div class="col-sm-10">
                @Html.TextBoxFor(m => m.Categories, new { @class = "form-control" })
                <div class="text-danger">@Html.ValidationMessageFor(m => m.Categories)</div>
            </div>
        </div>

        <div class="form-group row mb-1">
            <div class="col-sm-10 offset-sm-2">
                <button type="submit" class="btn btn-success rounded-0">保存!</button>
            </div>
        </div>
    </div>
}

<br />

<form action="@GlobalConfiguration.BasePath/Admin/DeleteEmoji/@Model.Emoji.Name">
    <button type="submit" class="btn btn-danger rounded-0">删除Emoji</button>
</form>
