diff --git a/TicketOffice/Pages/Management/Cities/Create.cshtml b/TicketOffice/Pages/Management/Cities/Create.cshtml new file mode 100644 index 0000000..1d40dc9 --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Create.cshtml @@ -0,0 +1,50 @@ +@page +@model TicketOffice.Pages.Management.Cities.CreateModel + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

City

+
+
+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + +
+
+ +
+
+
+
+ +
+ Back to List +
+ diff --git a/TicketOffice/Pages/Management/Cities/Create.cshtml.cs b/TicketOffice/Pages/Management/Cities/Create.cshtml.cs new file mode 100644 index 0000000..2cc9095 --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Create.cshtml.cs @@ -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 OnPostAsync() + { + if (!ModelState.IsValid) + { + return Page(); + } + + _context.City.Add(City); + await _context.SaveChangesAsync(); + + return RedirectToPage("./Index"); + } + } +} diff --git a/TicketOffice/Pages/Management/Cities/Delete.cshtml b/TicketOffice/Pages/Management/Cities/Delete.cshtml new file mode 100644 index 0000000..35bdf4d --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Delete.cshtml @@ -0,0 +1,52 @@ +@page +@model TicketOffice.Pages.Management.Cities.DeleteModel + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

City

+
+
+
+ @Html.DisplayNameFor(model => model.City.Name) +
+
+ @Html.DisplayFor(model => model.City.Name) +
+
+ @Html.DisplayNameFor(model => model.City.ArrivalTime) +
+
+ @Html.DisplayFor(model => model.City.ArrivalTime) +
+
+ @Html.DisplayNameFor(model => model.City.DepartureTime) +
+
+ @Html.DisplayFor(model => model.City.DepartureTime) +
+
+ @Html.DisplayNameFor(model => model.City.Distance) +
+
+ @Html.DisplayFor(model => model.City.Distance) +
+
+ @Html.DisplayNameFor(model => model.City.Route) +
+
+ @Html.DisplayFor(model => model.City.Route.Number) +
+
+ +
+ + | + Back to List +
+
diff --git a/TicketOffice/Pages/Management/Cities/Delete.cshtml.cs b/TicketOffice/Pages/Management/Cities/Delete.cshtml.cs new file mode 100644 index 0000000..61eeb0d --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Delete.cshtml.cs @@ -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 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 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"); + } + } +} diff --git a/TicketOffice/Pages/Management/Cities/Details.cshtml b/TicketOffice/Pages/Management/Cities/Details.cshtml new file mode 100644 index 0000000..28665e7 --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Details.cshtml @@ -0,0 +1,49 @@ +@page +@model TicketOffice.Pages.Management.Cities.DetailsModel + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

City

+
+
+
+ @Html.DisplayNameFor(model => model.City.Name) +
+
+ @Html.DisplayFor(model => model.City.Name) +
+
+ @Html.DisplayNameFor(model => model.City.ArrivalTime) +
+
+ @Html.DisplayFor(model => model.City.ArrivalTime) +
+
+ @Html.DisplayNameFor(model => model.City.DepartureTime) +
+
+ @Html.DisplayFor(model => model.City.DepartureTime) +
+
+ @Html.DisplayNameFor(model => model.City.Distance) +
+
+ @Html.DisplayFor(model => model.City.Distance) +
+
+ @Html.DisplayNameFor(model => model.City.Route) +
+
+ @Html.DisplayFor(model => model.City.Route.Number) +
+
+
+
+ Edit | + Back to List +
diff --git a/TicketOffice/Pages/Management/Cities/Details.cshtml.cs b/TicketOffice/Pages/Management/Cities/Details.cshtml.cs new file mode 100644 index 0000000..f6928c1 --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Details.cshtml.cs @@ -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 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(); + } + } +} diff --git a/TicketOffice/Pages/Management/Cities/Edit.cshtml b/TicketOffice/Pages/Management/Cities/Edit.cshtml new file mode 100644 index 0000000..153b2f7 --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Edit.cshtml @@ -0,0 +1,52 @@ +@page +@model TicketOffice.Pages.Management.Cities.EditModel + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

City

+
+
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+ +
+ Back to List +
+ diff --git a/TicketOffice/Pages/Management/Cities/Edit.cshtml.cs b/TicketOffice/Pages/Management/Cities/Edit.cshtml.cs new file mode 100644 index 0000000..95158c0 --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Edit.cshtml.cs @@ -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 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 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); + } + } +} diff --git a/TicketOffice/Pages/Management/Cities/Index.cshtml b/TicketOffice/Pages/Management/Cities/Index.cshtml new file mode 100644 index 0000000..8970c00 --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Index.cshtml @@ -0,0 +1,60 @@ +@page +@model TicketOffice.Pages.Management.Cities.IndexModel + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+ + + + + + + + + + + + +@foreach (var item in Model.City) { + + + + + + + + +} + +
+ @Html.DisplayNameFor(model => model.City[0].Name) + + @Html.DisplayNameFor(model => model.City[0].ArrivalTime) + + @Html.DisplayNameFor(model => model.City[0].DepartureTime) + + @Html.DisplayNameFor(model => model.City[0].Distance) + + @Html.DisplayNameFor(model => model.City[0].Route) +
+ @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.ArrivalTime) + + @Html.DisplayFor(modelItem => item.DepartureTime) + + @Html.DisplayFor(modelItem => item.Distance) + + @Html.DisplayFor(modelItem => item.Route.Number) + + Edit | + Details | + Delete +
diff --git a/TicketOffice/Pages/Management/Cities/Index.cshtml.cs b/TicketOffice/Pages/Management/Cities/Index.cshtml.cs new file mode 100644 index 0000000..e527ab4 --- /dev/null +++ b/TicketOffice/Pages/Management/Cities/Index.cshtml.cs @@ -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 { get;set; } + + public async Task OnGetAsync() + { + City = await _context.City + .Include(c => c.Route).ToListAsync(); + } + } +} diff --git a/TicketOffice/Pages/Management/Routes/Create.cshtml b/TicketOffice/Pages/Management/Routes/Create.cshtml new file mode 100644 index 0000000..4b52cf3 --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Create.cshtml @@ -0,0 +1,41 @@ +@page +@model TicketOffice.Pages.Management.Routes.CreateModel + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

Route

+
+
+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+ + + diff --git a/TicketOffice/Pages/Management/Routes/Create.cshtml.cs b/TicketOffice/Pages/Management/Routes/Create.cshtml.cs new file mode 100644 index 0000000..a1c23cf --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Create.cshtml.cs @@ -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 OnPostAsync() + { + if (!ModelState.IsValid) + { + return Page(); + } + + _context.Route.Add(Route); + await _context.SaveChangesAsync(); + + return RedirectToPage("./Index"); + } + } +} diff --git a/TicketOffice/Pages/Management/Routes/Delete.cshtml b/TicketOffice/Pages/Management/Routes/Delete.cshtml new file mode 100644 index 0000000..1e92bc9 --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Delete.cshtml @@ -0,0 +1,40 @@ +@page +@model TicketOffice.Pages.Management.Routes.DeleteModel + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

Route

+
+
+
+ @Html.DisplayNameFor(model => model.Route.Number) +
+
+ @Html.DisplayFor(model => model.Route.Number) +
+
+ @Html.DisplayNameFor(model => model.Route.Capacity) +
+
+ @Html.DisplayFor(model => model.Route.Capacity) +
+
+ @Html.DisplayNameFor(model => model.Route.RemainingCapacity) +
+
+ @Html.DisplayFor(model => model.Route.RemainingCapacity) +
+
+ +
+ + | + Back to List +
+
diff --git a/TicketOffice/Pages/Management/Routes/Delete.cshtml.cs b/TicketOffice/Pages/Management/Routes/Delete.cshtml.cs new file mode 100644 index 0000000..e082e8b --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Delete.cshtml.cs @@ -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 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 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"); + } + } +} diff --git a/TicketOffice/Pages/Management/Routes/Details.cshtml b/TicketOffice/Pages/Management/Routes/Details.cshtml new file mode 100644 index 0000000..9acc1d7 --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Details.cshtml @@ -0,0 +1,37 @@ +@page +@model TicketOffice.Pages.Management.Routes.DetailsModel + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

Route

+
+
+
+ @Html.DisplayNameFor(model => model.Route.Number) +
+
+ @Html.DisplayFor(model => model.Route.Number) +
+
+ @Html.DisplayNameFor(model => model.Route.Capacity) +
+
+ @Html.DisplayFor(model => model.Route.Capacity) +
+
+ @Html.DisplayNameFor(model => model.Route.RemainingCapacity) +
+
+ @Html.DisplayFor(model => model.Route.RemainingCapacity) +
+
+
+ diff --git a/TicketOffice/Pages/Management/Routes/Details.cshtml.cs b/TicketOffice/Pages/Management/Routes/Details.cshtml.cs new file mode 100644 index 0000000..7aecab2 --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Details.cshtml.cs @@ -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 OnGetAsync(int? id) + { + if (id == null) + { + return NotFound(); + } + + Route = await _context.Route.FirstOrDefaultAsync(m => m.Id == id); + + if (Route == null) + { + return NotFound(); + } + return Page(); + } + } +} diff --git a/TicketOffice/Pages/Management/Routes/Edit.cshtml b/TicketOffice/Pages/Management/Routes/Edit.cshtml new file mode 100644 index 0000000..7f44425 --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Edit.cshtml @@ -0,0 +1,42 @@ +@page +@model TicketOffice.Pages.Management.Routes.EditModel + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

Route

+
+
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+ + + diff --git a/TicketOffice/Pages/Management/Routes/Edit.cshtml.cs b/TicketOffice/Pages/Management/Routes/Edit.cshtml.cs new file mode 100644 index 0000000..a828be8 --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Edit.cshtml.cs @@ -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 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 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); + } + } +} diff --git a/TicketOffice/Pages/Management/Routes/Index.cshtml b/TicketOffice/Pages/Management/Routes/Index.cshtml new file mode 100644 index 0000000..6425ca0 --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Index.cshtml @@ -0,0 +1,48 @@ +@page +@model TicketOffice.Pages.Management.Routes.IndexModel + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+ + + + + + + + + + +@foreach (var item in Model.Route) { + + + + + + +} + +
+ @Html.DisplayNameFor(model => model.Route[0].Number) + + @Html.DisplayNameFor(model => model.Route[0].Capacity) + + @Html.DisplayNameFor(model => model.Route[0].RemainingCapacity) +
+ @Html.DisplayFor(modelItem => item.Number) + + @Html.DisplayFor(modelItem => item.Capacity) + + @Html.DisplayFor(modelItem => item.RemainingCapacity) + + Edit | + Details | + Delete +
diff --git a/TicketOffice/Pages/Management/Routes/Index.cshtml.cs b/TicketOffice/Pages/Management/Routes/Index.cshtml.cs new file mode 100644 index 0000000..a2e3180 --- /dev/null +++ b/TicketOffice/Pages/Management/Routes/Index.cshtml.cs @@ -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 { get;set; } + + public async Task OnGetAsync() + { + Route = await _context.Route.ToListAsync(); + } + } +} diff --git a/TicketOffice/Pages/Management/Tickets/Create.cshtml b/TicketOffice/Pages/Management/Tickets/Create.cshtml new file mode 100644 index 0000000..fe91e85 --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Create.cshtml @@ -0,0 +1,34 @@ +@page +@model TicketOffice.Pages.Management.Tickets.CreateModel + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

Ticket

+
+
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + + diff --git a/TicketOffice/Pages/Management/Tickets/Create.cshtml.cs b/TicketOffice/Pages/Management/Tickets/Create.cshtml.cs new file mode 100644 index 0000000..b27c66e --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Create.cshtml.cs @@ -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 OnPostAsync() + { + if (!ModelState.IsValid) + { + return Page(); + } + + _context.Ticket.Add(Ticket); + await _context.SaveChangesAsync(); + + return RedirectToPage("./Index"); + } + } +} diff --git a/TicketOffice/Pages/Management/Tickets/Delete.cshtml b/TicketOffice/Pages/Management/Tickets/Delete.cshtml new file mode 100644 index 0000000..08b7580 --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Delete.cshtml @@ -0,0 +1,34 @@ +@page +@model TicketOffice.Pages.Management.Tickets.DeleteModel + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

Ticket

+
+
+
+ @Html.DisplayNameFor(model => model.Ticket.User) +
+
+ @Html.DisplayFor(model => model.Ticket.User.Email) +
+
+ @Html.DisplayNameFor(model => model.Ticket.Route) +
+
+ @Html.DisplayFor(model => model.Ticket.Route.Number) +
+
+ +
+ + | + Back to List +
+
diff --git a/TicketOffice/Pages/Management/Tickets/Delete.cshtml.cs b/TicketOffice/Pages/Management/Tickets/Delete.cshtml.cs new file mode 100644 index 0000000..7c9ed69 --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Delete.cshtml.cs @@ -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 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 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"); + } + } +} diff --git a/TicketOffice/Pages/Management/Tickets/Details.cshtml b/TicketOffice/Pages/Management/Tickets/Details.cshtml new file mode 100644 index 0000000..4a71c11 --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Details.cshtml @@ -0,0 +1,31 @@ +@page +@model TicketOffice.Pages.Management.Tickets.DetailsModel + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

Ticket

+
+
+
+ @Html.DisplayNameFor(model => model.Ticket.User) +
+
+ @Html.DisplayFor(model => model.Ticket.User.Email) +
+
+ @Html.DisplayNameFor(model => model.Ticket.Route) +
+
+ @Html.DisplayFor(model => model.Ticket.Route.Number) +
+
+
+ diff --git a/TicketOffice/Pages/Management/Tickets/Details.cshtml.cs b/TicketOffice/Pages/Management/Tickets/Details.cshtml.cs new file mode 100644 index 0000000..df406fb --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Details.cshtml.cs @@ -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 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(); + } + } +} diff --git a/TicketOffice/Pages/Management/Tickets/Edit.cshtml b/TicketOffice/Pages/Management/Tickets/Edit.cshtml new file mode 100644 index 0000000..95ad28b --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Edit.cshtml @@ -0,0 +1,37 @@ +@page +@model TicketOffice.Pages.Management.Tickets.EditModel + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

Ticket

+
+
+
+
+
+ +
+ + + +
+
+ + + +
+
+ +
+
+
+
+ + + diff --git a/TicketOffice/Pages/Management/Tickets/Edit.cshtml.cs b/TicketOffice/Pages/Management/Tickets/Edit.cshtml.cs new file mode 100644 index 0000000..24057c5 --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Edit.cshtml.cs @@ -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 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 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); + } + } +} diff --git a/TicketOffice/Pages/Management/Tickets/Index.cshtml b/TicketOffice/Pages/Management/Tickets/Index.cshtml new file mode 100644 index 0000000..bdca7bb --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Index.cshtml @@ -0,0 +1,42 @@ +@page +@model TicketOffice.Pages.Management.Tickets.IndexModel + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+ + + + + + + + + +@foreach (var item in Model.Ticket) { + + + + + +} + +
+ @Html.DisplayNameFor(model => model.Ticket[0].User) + + @Html.DisplayNameFor(model => model.Ticket[0].Route) +
+ @Html.DisplayFor(modelItem => item.User.Email) + + @Html.DisplayFor(modelItem => item.Route.Number) + + Edit | + Details | + Delete +
diff --git a/TicketOffice/Pages/Management/Tickets/Index.cshtml.cs b/TicketOffice/Pages/Management/Tickets/Index.cshtml.cs new file mode 100644 index 0000000..3f8fb47 --- /dev/null +++ b/TicketOffice/Pages/Management/Tickets/Index.cshtml.cs @@ -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 { get;set; } + + public async Task OnGetAsync() + { + Ticket = await _context.Ticket + .Include(t => t.Route) + .Include(t => t.User).ToListAsync(); + } + } +} diff --git a/TicketOffice/Pages/Management/Users/Create.cshtml b/TicketOffice/Pages/Management/Users/Create.cshtml new file mode 100644 index 0000000..8a23425 --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Create.cshtml @@ -0,0 +1,56 @@ +@page +@model TicketOffice.Pages.Management.Users.CreateModel + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

User

+
+
+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+ +
+
+
+
+ + + diff --git a/TicketOffice/Pages/Management/Users/Create.cshtml.cs b/TicketOffice/Pages/Management/Users/Create.cshtml.cs new file mode 100644 index 0000000..df81cef --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Create.cshtml.cs @@ -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 OnPostAsync() + { + if (!ModelState.IsValid) + { + return Page(); + } + + _context.User.Add(User); + await _context.SaveChangesAsync(); + + return RedirectToPage("./Index"); + } + } +} diff --git a/TicketOffice/Pages/Management/Users/Delete.cshtml b/TicketOffice/Pages/Management/Users/Delete.cshtml new file mode 100644 index 0000000..fe89a44 --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Delete.cshtml @@ -0,0 +1,58 @@ +@page +@model TicketOffice.Pages.Management.Users.DeleteModel + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

User

+
+
+
+ @Html.DisplayNameFor(model => model.User.FirstName) +
+
+ @Html.DisplayFor(model => model.User.FirstName) +
+
+ @Html.DisplayNameFor(model => model.User.LastName) +
+
+ @Html.DisplayFor(model => model.User.LastName) +
+
+ @Html.DisplayNameFor(model => model.User.Patronymic) +
+
+ @Html.DisplayFor(model => model.User.Patronymic) +
+
+ @Html.DisplayNameFor(model => model.User.Email) +
+
+ @Html.DisplayFor(model => model.User.Email) +
+
+ @Html.DisplayNameFor(model => model.User.Password) +
+
+ @Html.DisplayFor(model => model.User.Password) +
+
+ @Html.DisplayNameFor(model => model.User.IsManager) +
+
+ @Html.DisplayFor(model => model.User.IsManager) +
+
+ +
+ + | + Back to List +
+
diff --git a/TicketOffice/Pages/Management/Users/Delete.cshtml.cs b/TicketOffice/Pages/Management/Users/Delete.cshtml.cs new file mode 100644 index 0000000..91b16cb --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Delete.cshtml.cs @@ -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 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 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"); + } + } +} diff --git a/TicketOffice/Pages/Management/Users/Details.cshtml b/TicketOffice/Pages/Management/Users/Details.cshtml new file mode 100644 index 0000000..58a3b02 --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Details.cshtml @@ -0,0 +1,55 @@ +@page +@model TicketOffice.Pages.Management.Users.DetailsModel + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

User

+
+
+
+ @Html.DisplayNameFor(model => model.User.FirstName) +
+
+ @Html.DisplayFor(model => model.User.FirstName) +
+
+ @Html.DisplayNameFor(model => model.User.LastName) +
+
+ @Html.DisplayFor(model => model.User.LastName) +
+
+ @Html.DisplayNameFor(model => model.User.Patronymic) +
+
+ @Html.DisplayFor(model => model.User.Patronymic) +
+
+ @Html.DisplayNameFor(model => model.User.Email) +
+
+ @Html.DisplayFor(model => model.User.Email) +
+
+ @Html.DisplayNameFor(model => model.User.Password) +
+
+ @Html.DisplayFor(model => model.User.Password) +
+
+ @Html.DisplayNameFor(model => model.User.IsManager) +
+
+ @Html.DisplayFor(model => model.User.IsManager) +
+
+
+ diff --git a/TicketOffice/Pages/Management/Users/Details.cshtml.cs b/TicketOffice/Pages/Management/Users/Details.cshtml.cs new file mode 100644 index 0000000..afe52ec --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Details.cshtml.cs @@ -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 OnGetAsync(int? id) + { + if (id == null) + { + return NotFound(); + } + + User = await _context.User.FirstOrDefaultAsync(m => m.Id == id); + + if (User == null) + { + return NotFound(); + } + return Page(); + } + } +} diff --git a/TicketOffice/Pages/Management/Users/Edit.cshtml b/TicketOffice/Pages/Management/Users/Edit.cshtml new file mode 100644 index 0000000..8654b42 --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Edit.cshtml @@ -0,0 +1,57 @@ +@page +@model TicketOffice.Pages.Management.Users.EditModel + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

User

+
+
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+ +
+
+
+
+ + + diff --git a/TicketOffice/Pages/Management/Users/Edit.cshtml.cs b/TicketOffice/Pages/Management/Users/Edit.cshtml.cs new file mode 100644 index 0000000..5fdb56c --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Edit.cshtml.cs @@ -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 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 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); + } + } +} diff --git a/TicketOffice/Pages/Management/Users/Index.cshtml b/TicketOffice/Pages/Management/Users/Index.cshtml new file mode 100644 index 0000000..efd5a61 --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Index.cshtml @@ -0,0 +1,66 @@ +@page +@model TicketOffice.Pages.Management.Users.IndexModel + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+ + + + + + + + + + + + + +@foreach (var item in Model.User) { + + + + + + + + + +} + +
+ @Html.DisplayNameFor(model => model.User[0].FirstName) + + @Html.DisplayNameFor(model => model.User[0].LastName) + + @Html.DisplayNameFor(model => model.User[0].Patronymic) + + @Html.DisplayNameFor(model => model.User[0].Email) + + @Html.DisplayNameFor(model => model.User[0].Password) + + @Html.DisplayNameFor(model => model.User[0].IsManager) +
+ @Html.DisplayFor(modelItem => item.FirstName) + + @Html.DisplayFor(modelItem => item.LastName) + + @Html.DisplayFor(modelItem => item.Patronymic) + + @Html.DisplayFor(modelItem => item.Email) + + @Html.DisplayFor(modelItem => item.Password) + + @Html.DisplayFor(modelItem => item.IsManager) + + Edit | + Details | + Delete +
diff --git a/TicketOffice/Pages/Management/Users/Index.cshtml.cs b/TicketOffice/Pages/Management/Users/Index.cshtml.cs new file mode 100644 index 0000000..094ddf0 --- /dev/null +++ b/TicketOffice/Pages/Management/Users/Index.cshtml.cs @@ -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 { get;set; } + + public async Task OnGetAsync() + { + User = await _context.User.ToListAsync(); + } + } +}