School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Add
</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container" id="addFormDiv">
<div class="row">
<div class="col-sm">
<div class="container text-left">
<form method="post" action="/add" id="addForm">
<h3>Add a news:</h3>
<div class="mb-1">
<label for="titleField" class="form-label">Title: </label><input type="text"
id="titleField"
class="form-control"
name="Title"
required
pattern="[0-9A-Za-z-.\:;]{5,30}" />
</div>
<div class="mb-1">
<label for="contentField" class="form-label">Content: </label><input type="text"
id="contentField"
class="form-control"
name="NewsText"
required
pattern="[0-9A-Za-z-.\:;]{10,256}" />
</div>
<div class="mb-1">
<label for="dateField" class="form-label">Date: </label><input type="date" id="dateField" class="form-control" required name="Date"/>
</div>
<div class="mb-1">
<label for="producerField" class="form-label">Producer: </label><input type="text"
id="producerField"
class="form-control"
name="Producer"
required
pattern="[0-9A-Za-z-]{5,30}" />
</div>
<div class="mb-1">
<label for="categoryField" class="form-label">Category: </label><input type="text"
id="categoryField"
class="form-control"
name="Category"
required
pattern="[0-9A-Za-z-]{5,30}" />
</div>
<button id="insertNewsButton"
type="submit"
class="btn btn-success mb-1">
Add News
</button>
</form>
<a type="submit"
class="btn btn-secondary mb-1"
name="returnButton"
href="/admin">
Return to admin
</a>
</div>
</div>
</div>
</div>
</body>
</html>
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Lab9.Views
{
public class AddModel : PageModel
{
public void OnGet()
{
}
}
}
@@ -0,0 +1,68 @@
@model IList<Lab9.Models.News>
<!DOCTYPE <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Admin
</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container text-center">
<h3>Welcome</h3>
<table class="container"
id="newsTable"
style="
margin: 30px;
border: 1px solid;
border-color: black;
border-collapse: collapse;
">
<thead>
<tr>
<th>Title</th>
<th>Content</th>
<th>Category</th>
<th>Date</th>
<th>Producer</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach(var item in Model)
{
<tr>
<td>@item.Title </td>
<td>@item.NewsText </td>
<td>@item.Category </td>
<td>@item.Date.ToString("dd-MM-yyyy") </td>
<td>@item.Producer</td>
<td>
<a class="btn btn-danger"
name="deleteButton"
href="/edit/@item.Id">
Edit
</a>
</td>
</tr>
}
</tbody>
<a type="button"
class="btn btn-primary"
name="addNewsButton"
href="/add"
style="margin: 30px">
Add news
</a>
<a type="button"
class="btn btn-dark"
name="logoutButton"
href="/logout"
style="margin: 30px">
Log out
</a>
</table>
</div>
</body>
</html>
@@ -0,0 +1,83 @@
@model Lab9.Models.News
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Edit
</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container" id="addFormDiv">
<div class="row">
<div class="col-sm">
<div class="container text-left">
<form method="post" action="/edit" id="addForm">
<h3>Edit a news:</h3>
<div class="mb-1">
<input type="hidden" id="idField" value="@Model.Id" name="Id" />
<label for="titleField" class="form-label">Title: </label><input type="text"
id="titleField"
class="form-control"
required
name="Title"
pattern="[0-9A-Za-z-.\:;]{5,30}"
value="@Model.Title" />
</div>
<div class="mb-1">
<label for="contentField" class="form-label">Content: </label><input type="text"
id="contentField"
class="form-control"
required
name="NewsText"
pattern="[0-9A-Za-z-.\:;]{10,256}"
value="@Model.NewsText" />
</div>
<div class="mb-1">
<label for="dateField" class="form-label">Date: </label><input type="date"
id="dateField"
class="form-control"
required
name="Date"
value="@Model.Date.ToString("yyyy-MM-dd")" />
</div>
<div class="mb-1">
<label for="producerField" class="form-label">Producer: </label><input type="text"
id="producerField"
class="form-control"
required
name="Producer"
pattern="[0-9A-Za-z-]{5,30}"
value="@Model.Producer" />
</div>
<div class="mb-1">
<label for="categoryField" class="form-label">Category: </label><input type="text"
id="categoryField"
class="form-control"
required
name="Category"
pattern="[0-9A-Za-z-]{5,30}"
value="@Model.Category" />
</div>
<button id="insertNewsButton"
type="submit"
class="btn btn-success mb-1">
Edit News
</button>
</form>
<a
class="btn btn-secondary mb-1"
name="returnButton"
href="/admin">
Return to admin
</a>
</div>
</div>
</div>
</div>
</body>
</html>
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Lab9.Views
{
public class EditModel : PageModel
{
public void OnGet()
{
}
}
}
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<title>News</title>
</head>
<body>
<div class="container text-center" id="index-page">
<h2>News</h2>
<a type="button"
class="btn btn-primary btn-block"
href="/login">
Login
</a>
<a type="button"
class="btn btn-primary btn-block"
href="/view">
View
</a>
</div>
</body>
</html>
@@ -0,0 +1,42 @@
<!DOCTYPE <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Login
</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<form method="post" action="/login" class="container">
<h2>Login</h2>
<div class="mb-3 mt-3">
<label for="username" class="form-label">Username:</label>
<input type="text"
class="form-control"
id="username"
placeholder="Enter username"
name="username" />
</div>
<div class="mb-3">
<label for="password" class="form-label">Password:</label>
<input type="password"
class="form-control"
id="password"
placeholder="Enter password"
name="password" />
</div>
<button class="btn btn-primary" name="loginButton" type="submit">
Login
</button>
<a class="btn btn-secondary" name="indexPage" href="/">
Cancel
</a>
</form>
@if(ViewBag.Error != null)
{
<script>
alert("@ViewBag.Error");
</script>
})
</body>
</html>
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Lab9.Views
{
public class LoginModel : PageModel
{
public void OnGet()
{
}
}
}
@@ -0,0 +1,83 @@
@model IList<Lab9.Models.News>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
View
</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
</head>
<body>
<div class="container text-center">
<h3>Welcome</h3>
<div class='dropdown'>
<button class='btn btn-secondary dropdown-toggle' type='button' id='dropdownMenuButton'
data-bs-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
Filter
</button>
<div class='dropdown-menu' aria-labelledby='dropdownMenuButton'>
<input class='dropdown-item' type="date" id="dateField" class="form-control" required>
<input class='dropdown-item' placeholder="Category" type="text" id="categoryField" class="form-control"
required>
<input class='dropdown-item' type="button" class="btn btn-primary" id="filterButton" value="Filter">
</div>
</div>
<table class="container" id="newsTable"
style="margin: 30px; border: 1px solid;border-color: black; border-collapse: collapse;">
<thead>
<tr>
<th>Title</th>
<th>Content</th>
<th>Category</th>
<th>Date</th>
<th>Producer</th>
</tr>
</thead>
<tbody id='tableBody'>
@foreach(var item in Model){
<tr>
<td>@item.Title </td>
<td>@item.NewsText </td>
<td>@item.Category </td>
<td>@item.Date.ToString("yyyy-MM-dd") </td>
<td>@item.Producer</td>
</tr>
}
</tbody>
<a class="btn btn-dark" name="backButton" href="/" style=" margin: 30px">Back</a>
</div>
<script>
$(document).ready(function () {
$('#filterButton').click(function () {
var date = $('#dateField').val();
var category = $('#categoryField').val();
$.ajax({
url: '/getnews',
type: 'POST',
data: {
date: date,
category: category,
},
success: function (response) {
$('#tableBody').empty();
for (var i = 0; i < response.length; i++) {
var newRow = "<tr><td>" + response[i].title + "</td><td>" + response[i].newsText +
"</td><td>" + response[i].category + "</td><td>" + response[i].date.slice(0,10) +
"</td><td>" + response[i].producer + "</td></tr>";
$('#tableBody').append(newRow);
}
}
});
});
});
</script>
</body>
</html>
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Lab9.Views
{
public class ViewModel : PageModel
{
public void OnGet()
{
}
}
}