@model ProductRequest
@* Generated from Custom MVC Template. *@
@* Model namespace using directive should be added to _ViewImports.cshtml. *@
@{
var containerDivClass = "container"; // "container-fluid" can be used for full width
var dateTimePickerClass = "datetimepicker"; // "jquery-datetimepicker" must be added as client side library
}
@{
/*
ViewBag and ViewData are the same collection (dictionary).
They carry extra data other than the model from a controller action to its view, or between views.
The value assigned will be shown in Views\Shared\_Layout.cshtml view's title tag of the head tag.
*/
ViewData["Title"] = "Product Create";
}
<div class="@containerDivClass">
<h1>@ViewData["Title"]</h1>
<hr />
</div>
<div class="@containerDivClass">
@if (TempData["Message"] is not null)
{
/*
TempData is used to carry extra data to the redirected controller action's view.
*/
<p class="text-danger">
@TempData["Message"]
</p>
}
<form asp-action="Create" autocomplete="off">
@Html.AntiForgeryToken()
<div asp-validation-summary="All" class="text-danger"></div> @* Use ModelOnly instead of All to see only service response messages in validation summary *@
<div class="row mb-3">
<label asp-for="Name" class="col-2 col-form-label fw-bold"></label>
<div class="col-10">
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
</div>
<div class="row mb-3">
<label asp-for="UnitPrice" class="col-2 col-form-label fw-bold"></label>
<div class="col-10">
<input asp-for="UnitPrice" class="form-control" />
<span asp-validation-for="UnitPrice" class="text-danger"></span>
</div>
</div>
<div class="row mb-3">
<label asp-for="StockAmount" class="col-2 col-form-label fw-bold"></label>
<div class="col-10">
<input asp-for="StockAmount" class="form-control" />
<span asp-validation-for="StockAmount" class="text-danger"></span>
</div>
</div>
<div class="row mb-3">
<label asp-for="ExpirationDate" class="col-2 col-form-label fw-bold"></label>
<div class="col-10">
<input asp-for="ExpirationDate" class="form-control @dateTimePickerClass" type="text" />
<span asp-validation-for="ExpirationDate" class="text-danger"></span>
</div>
</div>
<div class="row mb-3">
<label asp-for="CategoryId" class="col-2 col-form-label fw-bold"></label>
<div class="col-10">
<select asp-for="CategoryId" class="form-select" asp-items="ViewBag.CategoryId">
<option value="">-- Select --</option>
</select>
<span asp-validation-for="CategoryId" class="text-danger"></span>
</div>
</div>
@* Can be uncommented and used for many to many relationships, "entity" may be replaced with the related entity name in the controller and views. *@
<div class="row mb-3">
<label asp-for="StoreIds" class="col-2 col-form-label fw-bold"></label>
<div class="col-10">
<select multiple asp-for="StoreIds" class="form-select" asp-items="ViewBag.StoreIds"></select>
<span asp-validation-for="StoreIds" class="text-danger"></span>
</div>
</div>
<hr />
<div class="row mb-3">
<div class="offset-2 col-10">
<button type="submit" class="btn btn-primary">Save</button>
<button type="reset" class="btn btn-outline-primary">Reset</button>
<a asp-action="Index">Back to List</a>
</div>
</div>
</form>
</div>
@section Scripts {
@* Can be uncommented to use client-side validation using jQuery instead of server-side validation. *@
@*<partial name="_ValidationScriptsPartial" />*@
@* https://xdsoft.net/jqplugins/datetimepicker *@
<link href="~/lib/jquery-datetimepicker/jquery.datetimepicker.min.css" rel="stylesheet" />
<script src="~/lib/jquery-datetimepicker/jquery.datetimepicker.full.min.js"></script>
<script>
$(function () { // after the DOM is loaded
$(".datetimepicker").datetimepicker({
// for using only date
timepicker: false,
format: 'm/d/Y'
// for using date with time
// timepicker: true,
// format: 'm/d/Y H:i'
});
});
</script>
@* Select2 client-side library: *@
@* https://select2.org/ *@
<link href="~/lib/select2/css/select2.min.css" rel="stylesheet" />
<script src="~/lib/select2/js/select2.min.js"></script>
<script>
$(function() {
$("select").select2();
});
</script>
}