add categories(add, list, list news)

minor form changes
add news controller and views
This commit is contained in:
2024-07-28 18:35:11 +03:30
parent 30ac6724ca
commit a74072b491
22 changed files with 1092 additions and 148 deletions

107
Views/news/Create.cshtml Normal file
View File

@ -0,0 +1,107 @@
@model WebApplication1.Models.news
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<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.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.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.summary, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.summary, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.summary, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.cat, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.cat, new { htmlAttributes = new { @class = "form-control" } })
@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">
@Html.EditorFor(model => model.tag, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.tag, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.publishDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.publishDate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.publishDate, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.userID, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.userID, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.userID, "", 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.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.views, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.views, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.views, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>

104
Views/news/Delete.cshtml Normal file
View File

@ -0,0 +1,104 @@
@model WebApplication1.Models.news
@{
ViewBag.Title = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>news</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.title)
</dt>
<dd>
@Html.DisplayFor(model => model.title)
</dd>
<dt>
@Html.DisplayNameFor(model => model.image)
</dt>
<dd>
@Html.DisplayFor(model => model.image)
</dd>
<dt>
@Html.DisplayNameFor(model => model.link)
</dt>
<dd>
@Html.DisplayFor(model => model.link)
</dd>
<dt>
@Html.DisplayNameFor(model => model.summary)
</dt>
<dd>
@Html.DisplayFor(model => model.summary)
</dd>
<dt>
@Html.DisplayNameFor(model => model.cat)
</dt>
<dd>
@Html.DisplayFor(model => model.cat)
</dd>
<dt>
@Html.DisplayNameFor(model => model.tag)
</dt>
<dd>
@Html.DisplayFor(model => model.tag)
</dd>
<dt>
@Html.DisplayNameFor(model => model.publishDate)
</dt>
<dd>
@Html.DisplayFor(model => model.publishDate)
</dd>
<dt>
@Html.DisplayNameFor(model => model.userID)
</dt>
<dd>
@Html.DisplayFor(model => model.userID)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Content)
</dt>
<dd>
@Html.DisplayFor(model => model.Content)
</dd>
<dt>
@Html.DisplayNameFor(model => model.views)
</dt>
<dd>
@Html.DisplayFor(model => model.views)
</dd>
</dl>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
<div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-default" /> |
@Html.ActionLink("Back to List", "Index")
</div>
}
</div>

98
Views/news/Details.cshtml Normal file
View File

@ -0,0 +1,98 @@
@model WebApplication1.Models.news
@{
ViewBag.Title = "Details";
}
<h2>Details</h2>
<div>
<h4>news</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.title)
</dt>
<dd>
@Html.DisplayFor(model => model.title)
</dd>
<dt>
@Html.DisplayNameFor(model => model.image)
</dt>
<dd>
@Html.DisplayFor(model => model.image)
</dd>
<dt>
@Html.DisplayNameFor(model => model.link)
</dt>
<dd>
@Html.DisplayFor(model => model.link)
</dd>
<dt>
@Html.DisplayNameFor(model => model.summary)
</dt>
<dd>
@Html.DisplayFor(model => model.summary)
</dd>
<dt>
@Html.DisplayNameFor(model => model.cat)
</dt>
<dd>
@Html.DisplayFor(model => model.cat)
</dd>
<dt>
@Html.DisplayNameFor(model => model.tag)
</dt>
<dd>
@Html.DisplayFor(model => model.tag)
</dd>
<dt>
@Html.DisplayNameFor(model => model.publishDate)
</dt>
<dd>
@Html.DisplayFor(model => model.publishDate)
</dd>
<dt>
@Html.DisplayNameFor(model => model.userID)
</dt>
<dd>
@Html.DisplayFor(model => model.userID)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Content)
</dt>
<dd>
@Html.DisplayFor(model => model.Content)
</dd>
<dt>
@Html.DisplayNameFor(model => model.views)
</dt>
<dd>
@Html.DisplayFor(model => model.views)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
@Html.ActionLink("Back to List", "Index")
</p>

109
Views/news/Edit.cshtml Normal file
View File

@ -0,0 +1,109 @@
@model WebApplication1.Models.news
@{
ViewBag.Title = "Edit";
}
<h2>Edit</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>news</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.ID)
<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.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.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.summary, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.summary, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.summary, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.cat, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.cat, new { htmlAttributes = new { @class = "form-control" } })
@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">
@Html.EditorFor(model => model.tag, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.tag, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.publishDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.publishDate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.publishDate, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.userID, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.userID, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.userID, "", 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.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.views, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.views, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.views, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>

87
Views/news/Index.cshtml Normal file
View File

@ -0,0 +1,87 @@
@model IEnumerable<WebApplication1.Models.news>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.title)
</th>
<th>
@Html.DisplayNameFor(model => model.image)
</th>
<th>
@Html.DisplayNameFor(model => model.link)
</th>
<th>
@Html.DisplayNameFor(model => model.summary)
</th>
<th>
@Html.DisplayNameFor(model => model.cat)
</th>
<th>
@Html.DisplayNameFor(model => model.tag)
</th>
<th>
@Html.DisplayNameFor(model => model.publishDate)
</th>
<th>
@Html.DisplayNameFor(model => model.userID)
</th>
<th>
@Html.DisplayNameFor(model => model.Content)
</th>
<th>
@Html.DisplayNameFor(model => model.views)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.title)
</td>
<td>
@Html.DisplayFor(modelItem => item.image)
</td>
<td>
@Html.DisplayFor(modelItem => item.link)
</td>
<td>
@Html.DisplayFor(modelItem => item.summary)
</td>
<td>
@Html.DisplayFor(modelItem => item.cat)
</td>
<td>
@Html.DisplayFor(modelItem => item.tag)
</td>
<td>
@Html.DisplayFor(modelItem => item.publishDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.userID)
</td>
<td>
@Html.DisplayFor(modelItem => item.Content)
</td>
<td>
@Html.DisplayFor(modelItem => item.views)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
</td>
</tr>
}
</table>