mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
Dodawanie/Usuwanie
Dodawanie/Usuwanie (nie chce tu przeklinać)
This commit is contained in:
36
WebApp/Views/Events/Create.cshtml
Normal file
36
WebApp/Views/Events/Create.cshtml
Normal file
@@ -0,0 +1,36 @@
|
||||
@model WebApp.Entities.Event
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create Event";
|
||||
}
|
||||
|
||||
<h2>Create Event</h2>
|
||||
|
||||
<form asp-action="Create" method="post">
|
||||
<div class="form-group">
|
||||
<label asp-for="Name"></label>
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Place"></label>
|
||||
<input asp-for="Place" class="form-control" />
|
||||
<span asp-validation-for="Place" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Description"></label>
|
||||
<textarea asp-for="Description" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Date"></label>
|
||||
<input asp-for="Date" type="datetime-local" class="form-control" />
|
||||
<span asp-validation-for="Date" class="text-danger"></span>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{
|
||||
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||
}
|
||||
}
|
||||
12
WebApp/Views/Events/Create.cshtml.cs
Normal file
12
WebApp/Views/Events/Create.cshtml.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Views.Events
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,49 @@
|
||||
@{
|
||||
@model List<WebApp.Entities.Event>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Welcome</h1>
|
||||
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
|
||||
<a href="/Events/Create" class="btn btn-success">Create New Event</a>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2 class="mt-4">Lista wydarzeń</h2>
|
||||
|
||||
@if (Model.Any())
|
||||
{
|
||||
<table class="table table-bordered table-striped mt-3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nazwa</th>
|
||||
<th>Miejsce</th>
|
||||
<th>Data</th>
|
||||
<th>Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@item.Name</td>
|
||||
<td>@item.Place</td>
|
||||
<td>@item.Date.ToString("yyyy-MM-dd HH:mm")</td>
|
||||
<td>
|
||||
<form asp-action="Delete" asp-controller="Events" method="post" style="display:inline;">
|
||||
<input type="hidden" name="id" value="@item.Id" />
|
||||
<button type="submit" class="btn btn-danger" onclick="return confirm('Na pewno chcesz usunąć to wydarzenie?')">Usuń</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="mt-3">Brak wydarzeń do wyświetlenia.</p>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user