diff --git a/Template/StuzkovakWeb/Areas/Admin/Controllers/InvitesController.cs b/Template/StuzkovakWeb/Areas/Admin/Controllers/InvitesController.cs new file mode 100644 index 0000000..ef360a1 --- /dev/null +++ b/Template/StuzkovakWeb/Areas/Admin/Controllers/InvitesController.cs @@ -0,0 +1,34 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using StuzkovakWeb.Data; +using StuzkovakWeb.ViewModels; + +namespace StuzkovakWeb.Areas.Admin.Controllers; + +public class InvitesController : AdminBaseController +{ + private readonly AppDbContext _context; + + public InvitesController(AppDbContext context) + { + _context = context; + } + + public async Task Index() + { + var invites = await _context.Invites.ToListAsync(); + return View(invites); + } + + public async Task Details(Guid id) + { + var invite = await _context.Invites.FirstOrDefaultAsync(i => i.Id == id); + if (invite == null) return NotFound(); + return View(new AdminInviteDetailViewModel + { + Id = invite.Id, + TeacherName = invite.TeacherName, + IsAccepted = invite.IsAccepted + }); + } +} \ No newline at end of file diff --git a/Template/StuzkovakWeb/Areas/Admin/Views/Invites/Details.cshtml b/Template/StuzkovakWeb/Areas/Admin/Views/Invites/Details.cshtml new file mode 100644 index 0000000..6bac467 --- /dev/null +++ b/Template/StuzkovakWeb/Areas/Admin/Views/Invites/Details.cshtml @@ -0,0 +1,40 @@ +@model StuzkovakWeb.ViewModels.AdminInviteDetailViewModel +@{ + ViewData["Title"] = "Detail pozvánky"; +} + + + +@if (TempData["SuccessMessage"] != null) +{ +
@TempData["SuccessMessage"]
+} + +
+
+

Pozvánka pro učitele: @Model.TeacherName

+
+
+
+
ID
+
@Model.Id
+ +
Učitel
+
@Model.TeacherName
+ +
Přijetí
+
@{ + if (Model.IsAccepted == true) + { + Ano + } + else if (Model.IsAccepted == false) + { + Ne + } + }
+
+
+
diff --git a/Template/StuzkovakWeb/Areas/Admin/Views/Invites/Index.cshtml b/Template/StuzkovakWeb/Areas/Admin/Views/Invites/Index.cshtml new file mode 100644 index 0000000..aed58e6 --- /dev/null +++ b/Template/StuzkovakWeb/Areas/Admin/Views/Invites/Index.cshtml @@ -0,0 +1,41 @@ +@model List +@{ + ViewData["Title"] = "Invite Management"; +} + +
+

Pozvánky

+
+ + + + + + + + + + + + @foreach (var invite in Model) + { + + + + + + + } + +
IDUčitelPotvrzeníActions
@invite.Id@invite.TeacherName@{ + if (invite.IsAccepted == true) + { + Ano + } + else if (invite.IsAccepted == false) + { + Ne + } + } + Details +
diff --git a/Template/StuzkovakWeb/Controllers/AuthController.cs b/Template/StuzkovakWeb/Controllers/AuthController.cs index eb73200..829630e 100644 --- a/Template/StuzkovakWeb/Controllers/AuthController.cs +++ b/Template/StuzkovakWeb/Controllers/AuthController.cs @@ -36,16 +36,6 @@ public class AuthController : Controller return View(new AuthLoginViewModel { ReturnUrl = returnUrl }); } - [HttpGet] - [AllowAnonymous] - public IActionResult Register(string? returnUrl) - { - if (User.Identity?.IsAuthenticated == true) - return RedirectToAction("Index", "Home"); - - return View(new AuthRegisterViewModel { ReturnUrl = returnUrl }); - } - [HttpGet] public IActionResult AccessDenied() => View(); @@ -100,36 +90,6 @@ public class AuthController : Controller return RedirectToAction("Index", "Home"); } - [HttpPost] - [AllowAnonymous] - [ValidateAntiForgeryToken] - public async Task Register(AuthRegisterViewModel model) - { - if (!ModelState.IsValid) return View(model); - - var user = new UserEntity - { - UserName = model.UserName.Trim(), - Email = model.Email.Trim().ToLower(), - }; - - var result = await _userManager.CreateAsync(user, model.Password); - if (!result.Succeeded) - { - foreach (var error in result.Errors) - ModelState.AddModelError(string.Empty, error.Description); - return View(model); - } - - await _userManager.AddToRoleAsync(user, "User"); - _logger.LogInformation("User {UserName} registered.", user.UserName); - - if (!string.IsNullOrEmpty(model.ReturnUrl) && Url.IsLocalUrl(model.ReturnUrl)) - return Redirect(model.ReturnUrl); - - return RedirectToAction("Login"); - } - [HttpPost] [Authorize] [ValidateAntiForgeryToken] diff --git a/Template/StuzkovakWeb/Controllers/HomeController.cs b/Template/StuzkovakWeb/Controllers/HomeController.cs index 86be966..b7d1c01 100644 --- a/Template/StuzkovakWeb/Controllers/HomeController.cs +++ b/Template/StuzkovakWeb/Controllers/HomeController.cs @@ -11,11 +11,6 @@ public class HomeController : Controller return View(); } - public IActionResult Privacy() - { - return View(); - } - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/Template/StuzkovakWeb/Data/AppDbContext.cs b/Template/StuzkovakWeb/Data/AppDbContext.cs index 8f132ec..2716ec7 100644 --- a/Template/StuzkovakWeb/Data/AppDbContext.cs +++ b/Template/StuzkovakWeb/Data/AppDbContext.cs @@ -10,4 +10,6 @@ public class AppDbContext : IdentityDbContext : base(options) { } + + public DbSet Invites { get; set; } } diff --git a/Template/StuzkovakWeb/Entities/InviteEntity.cs b/Template/StuzkovakWeb/Entities/InviteEntity.cs new file mode 100644 index 0000000..9e6f20a --- /dev/null +++ b/Template/StuzkovakWeb/Entities/InviteEntity.cs @@ -0,0 +1,8 @@ +namespace StuzkovakWeb.Entities; + +public class InviteEntity +{ + public Guid Id { get; set; } = Guid.NewGuid(); + public required string TeacherName { get; set; } + public bool? IsAccepted { get; set; } = null; +} \ No newline at end of file diff --git a/Template/StuzkovakWeb/ViewModels/AdminInviteDetailViewModel.cs b/Template/StuzkovakWeb/ViewModels/AdminInviteDetailViewModel.cs new file mode 100644 index 0000000..0d80218 --- /dev/null +++ b/Template/StuzkovakWeb/ViewModels/AdminInviteDetailViewModel.cs @@ -0,0 +1,8 @@ +namespace StuzkovakWeb.ViewModels; + +public class AdminInviteDetailViewModel +{ + public Guid Id { get; set; } + public string TeacherName { get; set; } + public bool? IsAccepted { get; set; } +} \ No newline at end of file diff --git a/Template/StuzkovakWeb/Models/UserWithRolesViewModel.cs b/Template/StuzkovakWeb/ViewModels/UserWithRolesViewModel.cs similarity index 100% rename from Template/StuzkovakWeb/Models/UserWithRolesViewModel.cs rename to Template/StuzkovakWeb/ViewModels/UserWithRolesViewModel.cs diff --git a/Template/StuzkovakWeb/Views/Auth/Register.cshtml b/Template/StuzkovakWeb/Views/Auth/Register.cshtml deleted file mode 100644 index f7b4776..0000000 --- a/Template/StuzkovakWeb/Views/Auth/Register.cshtml +++ /dev/null @@ -1,50 +0,0 @@ -@model AuthRegisterViewModel - -
-
-
-
-

Register

- -
- @Html.AntiForgeryToken() - - - -
- - - -
- -
- - - -
- -
- - - -
- -
- - - -
- - -
- -
-
-
-
-
-
- -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } -} \ No newline at end of file diff --git a/Template/StuzkovakWeb/Views/Shared/_Layout.cshtml b/Template/StuzkovakWeb/Views/Shared/_Layout.cshtml index 1c01c2f..a203a63 100644 --- a/Template/StuzkovakWeb/Views/Shared/_Layout.cshtml +++ b/Template/StuzkovakWeb/Views/Shared/_Layout.cshtml @@ -1,9 +1,9 @@  - + - @ViewData["Title"] - StuzkovakWeb + @ViewData["Title"] – Stužkovák 4.EP @@ -13,20 +13,12 @@