feat: add Razor Pages using Entity Framework (CRUD)

This commit is contained in:
cuqmbr 2022-03-26 22:28:14 +02:00
parent 2ee2ed46e9
commit cbb741a057
40 changed files with 1980 additions and 0 deletions

View File

@ -0,0 +1,50 @@
@page
@model TicketOffice.Pages.Management.Cities.CreateModel
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>City</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="City.Name" class="control-label"></label>
<input asp-for="City.Name" class="form-control" />
<span asp-validation-for="City.Name" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="City.ArrivalTime" class="control-label"></label>
<input asp-for="City.ArrivalTime" class="form-control" />
<span asp-validation-for="City.ArrivalTime" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="City.DepartureTime" class="control-label"></label>
<input asp-for="City.DepartureTime" class="form-control" />
<span asp-validation-for="City.DepartureTime" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="City.Distance" class="control-label"></label>
<input asp-for="City.Distance" class="form-control" />
<span asp-validation-for="City.Distance" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="City.RouteId" class="control-label"></label>
<select asp-for="City.RouteId" class ="form-control" asp-items="ViewBag.RouteId"></select>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="Index">Back to List</a>
</div>

View File

@ -0,0 +1,46 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Cities
{
public class CreateModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public CreateModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public IActionResult OnGet()
{
ViewData["RouteId"] = new SelectList(_context.Route, "Id", "Number");
return Page();
}
[BindProperty]
public City City { get; set; }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.City.Add(City);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,52 @@
@page
@model TicketOffice.Pages.Management.Cities.DeleteModel
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>City</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.Name)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.Name)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.ArrivalTime)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.ArrivalTime)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.DepartureTime)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.DepartureTime)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.Distance)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.Distance)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.Route)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.Route.Number)
</dd>
</dl>
<form method="post">
<input type="hidden" asp-for="City.Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,61 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Cities
{
public class DeleteModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public DeleteModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
[BindProperty]
public City City { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
City = await _context.City
.Include(c => c.Route).FirstOrDefaultAsync(m => m.Id == id);
if (City == null)
{
return NotFound();
}
return Page();
}
public async Task<IActionResult> OnPostAsync(int? id)
{
if (id == null)
{
return NotFound();
}
City = await _context.City.FindAsync(id);
if (City != null)
{
_context.City.Remove(City);
await _context.SaveChangesAsync();
}
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,49 @@
@page
@model TicketOffice.Pages.Management.Cities.DetailsModel
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>City</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.Name)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.Name)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.ArrivalTime)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.ArrivalTime)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.DepartureTime)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.DepartureTime)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.Distance)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.Distance)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.City.Route)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.City.Route.Number)
</dd>
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.City.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,42 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Cities
{
public class DetailsModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public DetailsModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public City City { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
City = await _context.City
.Include(c => c.Route).FirstOrDefaultAsync(m => m.Id == id);
if (City == null)
{
return NotFound();
}
return Page();
}
}
}

View File

@ -0,0 +1,52 @@
@page
@model TicketOffice.Pages.Management.Cities.EditModel
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>City</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="City.Id" />
<div class="form-group">
<label asp-for="City.Name" class="control-label"></label>
<input asp-for="City.Name" class="form-control" />
<span asp-validation-for="City.Name" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="City.ArrivalTime" class="control-label"></label>
<input asp-for="City.ArrivalTime" class="form-control" />
<span asp-validation-for="City.ArrivalTime" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="City.DepartureTime" class="control-label"></label>
<input asp-for="City.DepartureTime" class="form-control" />
<span asp-validation-for="City.DepartureTime" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="City.Distance" class="control-label"></label>
<input asp-for="City.Distance" class="form-control" />
<span asp-validation-for="City.Distance" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="City.RouteId" class="control-label"></label>
<select asp-for="City.RouteId" class="form-control" asp-items="ViewBag.RouteId"></select>
<span asp-validation-for="City.RouteId" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,80 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Cities
{
public class EditModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public EditModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
[BindProperty]
public City City { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
City = await _context.City
.Include(c => c.Route).FirstOrDefaultAsync(m => m.Id == id);
if (City == null)
{
return NotFound();
}
ViewData["RouteId"] = new SelectList(_context.Route, "Id", "Number");
return Page();
}
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Attach(City).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!CityExists(City.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToPage("./Index");
}
private bool CityExists(int id)
{
return _context.City.Any(e => e.Id == id);
}
}
}

View File

@ -0,0 +1,60 @@
@page
@model TicketOffice.Pages.Management.Cities.IndexModel
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-page="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.City[0].Name)
</th>
<th>
@Html.DisplayNameFor(model => model.City[0].ArrivalTime)
</th>
<th>
@Html.DisplayNameFor(model => model.City[0].DepartureTime)
</th>
<th>
@Html.DisplayNameFor(model => model.City[0].Distance)
</th>
<th>
@Html.DisplayNameFor(model => model.City[0].Route)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.City) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.ArrivalTime)
</td>
<td>
@Html.DisplayFor(modelItem => item.DepartureTime)
</td>
<td>
@Html.DisplayFor(modelItem => item.Distance)
</td>
<td>
@Html.DisplayFor(modelItem => item.Route.Number)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,31 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Cities
{
public class IndexModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public IndexModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public IList<City> City { get;set; }
public async Task OnGetAsync()
{
City = await _context.City
.Include(c => c.Route).ToListAsync();
}
}
}

View File

@ -0,0 +1,41 @@
@page
@model TicketOffice.Pages.Management.Routes.CreateModel
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>Route</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Route.Number" class="control-label"></label>
<input asp-for="Route.Number" class="form-control" />
<span asp-validation-for="Route.Number" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Route.Capacity" class="control-label"></label>
<input asp-for="Route.Capacity" class="form-control" />
<span asp-validation-for="Route.Capacity" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Route.RemainingCapacity" class="control-label"></label>
<input asp-for="Route.RemainingCapacity" class="form-control" />
<span asp-validation-for="Route.RemainingCapacity" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="Index">Back to List</a>
</div>

View File

@ -0,0 +1,46 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using TicketOffice.Data;
using TicketOffice.Models;
using Route = TicketOffice.Models.Route;
namespace TicketOffice.Pages.Management.Routes
{
public class CreateModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public CreateModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public IActionResult OnGet()
{
return Page();
}
[BindProperty]
public Route Route { get; set; }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Route.Add(Route);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,40 @@
@page
@model TicketOffice.Pages.Management.Routes.DeleteModel
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Route</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Route.Number)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Route.Number)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Route.Capacity)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Route.Capacity)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Route.RemainingCapacity)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Route.RemainingCapacity)
</dd>
</dl>
<form method="post">
<input type="hidden" asp-for="Route.Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,61 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
using Route = TicketOffice.Models.Route;
namespace TicketOffice.Pages.Management.Routes
{
public class DeleteModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public DeleteModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
[BindProperty]
public Route Route { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
Route = await _context.Route.FirstOrDefaultAsync(m => m.Id == id);
if (Route == null)
{
return NotFound();
}
return Page();
}
public async Task<IActionResult> OnPostAsync(int? id)
{
if (id == null)
{
return NotFound();
}
Route = await _context.Route.FindAsync(id);
if (Route != null)
{
_context.Route.Remove(Route);
await _context.SaveChangesAsync();
}
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,37 @@
@page
@model TicketOffice.Pages.Management.Routes.DetailsModel
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>Route</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Route.Number)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Route.Number)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Route.Capacity)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Route.Capacity)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Route.RemainingCapacity)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Route.RemainingCapacity)
</dd>
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.Route.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,42 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
using Route = TicketOffice.Models.Route;
namespace TicketOffice.Pages.Management.Routes
{
public class DetailsModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public DetailsModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public Route Route { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
Route = await _context.Route.FirstOrDefaultAsync(m => m.Id == id);
if (Route == null)
{
return NotFound();
}
return Page();
}
}
}

View File

@ -0,0 +1,42 @@
@page
@model TicketOffice.Pages.Management.Routes.EditModel
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>Route</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Route.Id" />
<div class="form-group">
<label asp-for="Route.Number" class="control-label"></label>
<input asp-for="Route.Number" class="form-control" />
<span asp-validation-for="Route.Number" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Route.Capacity" class="control-label"></label>
<input asp-for="Route.Capacity" class="form-control" />
<span asp-validation-for="Route.Capacity" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Route.RemainingCapacity" class="control-label"></label>
<input asp-for="Route.RemainingCapacity" class="form-control" />
<span asp-validation-for="Route.RemainingCapacity" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,79 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
using Route = TicketOffice.Models.Route;
namespace TicketOffice.Pages.Management.Routes
{
public class EditModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public EditModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
[BindProperty]
public Route Route { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
Route = await _context.Route.FirstOrDefaultAsync(m => m.Id == id);
if (Route == null)
{
return NotFound();
}
return Page();
}
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Attach(Route).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!RouteExists(Route.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToPage("./Index");
}
private bool RouteExists(int id)
{
return _context.Route.Any(e => e.Id == id);
}
}
}

View File

@ -0,0 +1,48 @@
@page
@model TicketOffice.Pages.Management.Routes.IndexModel
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-page="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Route[0].Number)
</th>
<th>
@Html.DisplayNameFor(model => model.Route[0].Capacity)
</th>
<th>
@Html.DisplayNameFor(model => model.Route[0].RemainingCapacity)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Route) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Number)
</td>
<td>
@Html.DisplayFor(modelItem => item.Capacity)
</td>
<td>
@Html.DisplayFor(modelItem => item.RemainingCapacity)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,31 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
using Route = TicketOffice.Models.Route;
namespace TicketOffice.Pages.Management.Routes
{
public class IndexModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public IndexModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public IList<Route> Route { get;set; }
public async Task OnGetAsync()
{
Route = await _context.Route.ToListAsync();
}
}
}

View File

@ -0,0 +1,34 @@
@page
@model TicketOffice.Pages.Management.Tickets.CreateModel
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>Ticket</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Ticket.UserId" class="control-label"></label>
<select asp-for="Ticket.UserId" class ="form-control" asp-items="ViewBag.UserId"></select>
</div>
<div class="form-group">
<label asp-for="Ticket.RouteId" class="control-label"></label>
<select asp-for="Ticket.RouteId" class ="form-control" asp-items="ViewBag.RouteId"></select>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="Index">Back to List</a>
</div>

View File

@ -0,0 +1,47 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Tickets
{
public class CreateModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public CreateModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public IActionResult OnGet()
{
ViewData["RouteId"] = new SelectList(_context.Route, "Id", "Number");
ViewData["UserId"] = new SelectList(_context.User, "Id", "Email");
return Page();
}
[BindProperty]
public Ticket Ticket { get; set; }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Ticket.Add(Ticket);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,34 @@
@page
@model TicketOffice.Pages.Management.Tickets.DeleteModel
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Ticket</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Ticket.User)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Ticket.User.Email)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Ticket.Route)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Ticket.Route.Number)
</dd>
</dl>
<form method="post">
<input type="hidden" asp-for="Ticket.Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,62 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Tickets
{
public class DeleteModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public DeleteModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
[BindProperty]
public Ticket Ticket { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
Ticket = await _context.Ticket
.Include(t => t.Route)
.Include(t => t.User).FirstOrDefaultAsync(m => m.Id == id);
if (Ticket == null)
{
return NotFound();
}
return Page();
}
public async Task<IActionResult> OnPostAsync(int? id)
{
if (id == null)
{
return NotFound();
}
Ticket = await _context.Ticket.FindAsync(id);
if (Ticket != null)
{
_context.Ticket.Remove(Ticket);
await _context.SaveChangesAsync();
}
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,31 @@
@page
@model TicketOffice.Pages.Management.Tickets.DetailsModel
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>Ticket</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Ticket.User)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Ticket.User.Email)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Ticket.Route)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Ticket.Route.Number)
</dd>
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.Ticket.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,43 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Tickets
{
public class DetailsModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public DetailsModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public Ticket Ticket { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
Ticket = await _context.Ticket
.Include(t => t.Route)
.Include(t => t.User).FirstOrDefaultAsync(m => m.Id == id);
if (Ticket == null)
{
return NotFound();
}
return Page();
}
}
}

View File

@ -0,0 +1,37 @@
@page
@model TicketOffice.Pages.Management.Tickets.EditModel
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>Ticket</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Ticket.Id" />
<div class="form-group">
<label asp-for="Ticket.UserId" class="control-label"></label>
<select asp-for="Ticket.UserId" class="form-control" asp-items="ViewBag.UserId"></select>
<span asp-validation-for="Ticket.UserId" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Ticket.RouteId" class="control-label"></label>
<select asp-for="Ticket.RouteId" class="form-control" asp-items="ViewBag.RouteId"></select>
<span asp-validation-for="Ticket.RouteId" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,82 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Tickets
{
public class EditModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public EditModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
[BindProperty]
public Ticket Ticket { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
Ticket = await _context.Ticket
.Include(t => t.Route)
.Include(t => t.User).FirstOrDefaultAsync(m => m.Id == id);
if (Ticket == null)
{
return NotFound();
}
ViewData["RouteId"] = new SelectList(_context.Route, "Id", "Number");
ViewData["UserId"] = new SelectList(_context.User, "Id", "Email");
return Page();
}
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Attach(Ticket).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!TicketExists(Ticket.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToPage("./Index");
}
private bool TicketExists(int id)
{
return _context.Ticket.Any(e => e.Id == id);
}
}
}

View File

@ -0,0 +1,42 @@
@page
@model TicketOffice.Pages.Management.Tickets.IndexModel
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-page="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Ticket[0].User)
</th>
<th>
@Html.DisplayNameFor(model => model.Ticket[0].Route)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Ticket) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.User.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.Route.Number)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,32 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Tickets
{
public class IndexModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public IndexModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public IList<Ticket> Ticket { get;set; }
public async Task OnGetAsync()
{
Ticket = await _context.Ticket
.Include(t => t.Route)
.Include(t => t.User).ToListAsync();
}
}
}

View File

@ -0,0 +1,56 @@
@page
@model TicketOffice.Pages.Management.Users.CreateModel
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>User</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="User.FirstName" class="control-label"></label>
<input asp-for="User.FirstName" class="form-control" />
<span asp-validation-for="User.FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="User.LastName" class="control-label"></label>
<input asp-for="User.LastName" class="form-control" />
<span asp-validation-for="User.LastName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="User.Patronymic" class="control-label"></label>
<input asp-for="User.Patronymic" class="form-control" />
<span asp-validation-for="User.Patronymic" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="User.Email" class="control-label"></label>
<input asp-for="User.Email" class="form-control" />
<span asp-validation-for="User.Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="User.Password" class="control-label"></label>
<input asp-for="User.Password" class="form-control" />
<span asp-validation-for="User.Password" class="text-danger"></span>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" asp-for="User.IsManager" /> @Html.DisplayNameFor(model => model.User.IsManager)
</label>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="Index">Back to List</a>
</div>

View File

@ -0,0 +1,45 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Users
{
public class CreateModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public CreateModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public IActionResult OnGet()
{
return Page();
}
[BindProperty]
public User User { get; set; }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.User.Add(User);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,58 @@
@page
@model TicketOffice.Pages.Management.Users.DeleteModel
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>User</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.FirstName)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.FirstName)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.LastName)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.LastName)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.Patronymic)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.Patronymic)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.Email)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.Email)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.Password)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.Password)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.IsManager)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.IsManager)
</dd>
</dl>
<form method="post">
<input type="hidden" asp-for="User.Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,60 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Users
{
public class DeleteModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public DeleteModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
[BindProperty]
public User User { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
User = await _context.User.FirstOrDefaultAsync(m => m.Id == id);
if (User == null)
{
return NotFound();
}
return Page();
}
public async Task<IActionResult> OnPostAsync(int? id)
{
if (id == null)
{
return NotFound();
}
User = await _context.User.FindAsync(id);
if (User != null)
{
_context.User.Remove(User);
await _context.SaveChangesAsync();
}
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,55 @@
@page
@model TicketOffice.Pages.Management.Users.DetailsModel
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>User</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.FirstName)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.FirstName)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.LastName)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.LastName)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.Patronymic)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.Patronymic)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.Email)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.Email)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.Password)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.Password)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.User.IsManager)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.User.IsManager)
</dd>
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.User.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,41 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Users
{
public class DetailsModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public DetailsModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public User User { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
User = await _context.User.FirstOrDefaultAsync(m => m.Id == id);
if (User == null)
{
return NotFound();
}
return Page();
}
}
}

View File

@ -0,0 +1,57 @@
@page
@model TicketOffice.Pages.Management.Users.EditModel
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>User</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="User.Id" />
<div class="form-group">
<label asp-for="User.FirstName" class="control-label"></label>
<input asp-for="User.FirstName" class="form-control" />
<span asp-validation-for="User.FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="User.LastName" class="control-label"></label>
<input asp-for="User.LastName" class="form-control" />
<span asp-validation-for="User.LastName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="User.Patronymic" class="control-label"></label>
<input asp-for="User.Patronymic" class="form-control" />
<span asp-validation-for="User.Patronymic" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="User.Email" class="control-label"></label>
<input asp-for="User.Email" class="form-control" />
<span asp-validation-for="User.Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="User.Password" class="control-label"></label>
<input asp-for="User.Password" class="form-control" />
<span asp-validation-for="User.Password" class="text-danger"></span>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" asp-for="User.IsManager" /> @Html.DisplayNameFor(model => model.User.IsManager)
</label>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,78 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Users
{
public class EditModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public EditModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
[BindProperty]
public User User { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
{
return NotFound();
}
User = await _context.User.FirstOrDefaultAsync(m => m.Id == id);
if (User == null)
{
return NotFound();
}
return Page();
}
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Attach(User).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!UserExists(User.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToPage("./Index");
}
private bool UserExists(int id)
{
return _context.User.Any(e => e.Id == id);
}
}
}

View File

@ -0,0 +1,66 @@
@page
@model TicketOffice.Pages.Management.Users.IndexModel
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-page="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.User[0].FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.User[0].LastName)
</th>
<th>
@Html.DisplayNameFor(model => model.User[0].Patronymic)
</th>
<th>
@Html.DisplayNameFor(model => model.User[0].Email)
</th>
<th>
@Html.DisplayNameFor(model => model.User[0].Password)
</th>
<th>
@Html.DisplayNameFor(model => model.User[0].IsManager)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.User) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Patronymic)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.Password)
</td>
<td>
@Html.DisplayFor(modelItem => item.IsManager)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,30 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using TicketOffice.Data;
using TicketOffice.Models;
namespace TicketOffice.Pages.Management.Users
{
public class IndexModel : PageModel
{
private readonly TicketOffice.Data.TicketOfficeContext _context;
public IndexModel(TicketOffice.Data.TicketOfficeContext context)
{
_context = context;
}
public IList<User> User { get;set; }
public async Task OnGetAsync()
{
User = await _context.User.ToListAsync();
}
}
}