From f35a7aecd313547a6f6478a056fb2d5593f1c07b Mon Sep 17 00:00:00 2001
From: Syndamia
Date: Sat, 15 May 2021 22:20:53 +0300
Subject: Big daddy refactor
---
.../Web/Configurations/ControllerUserMappings.cs | 18 ---
ExamTemplate/Web/Controllers/AccountController.cs | 146 ---------------------
ExamTemplate/Web/Controllers/HomeController.cs | 33 -----
.../Web/ExamTemplate.Web.Models/BaseWebModel.cs | 9 ++
.../Web/ExamTemplate.Web.Models/ErrorViewModel.cs | 9 ++
.../ExamTemplate.Web.Models.csproj | 7 +
.../User/EditUserWebModel.cs | 19 +++
.../User/LoginUserWebModel.cs | 15 +++
.../User/RegisterUserWebModel.cs | 23 ++++
.../ExamTemplate.Web.Models/User/UserWebModel.cs | 9 ++
.../Configurations/ControllerUserMappings.cs | 18 +++
.../Controllers/AccountController.cs | 146 +++++++++++++++++++++
.../ExamTemplate.Web/Controllers/HomeController.cs | 33 +++++
.../Web/ExamTemplate.Web/ExamTemplate.Web.csproj | 20 +++
ExamTemplate/Web/ExamTemplate.Web/Program.cs | 20 +++
.../Properties/launchSettings.json | 27 ++++
ExamTemplate/Web/ExamTemplate.Web/Startup.cs | 134 +++++++++++++++++++
.../Web/ExamTemplate.Web/Views/Account/Edit.cshtml | 20 +++
.../ExamTemplate.Web/Views/Account/Login.cshtml | 23 ++++
.../ExamTemplate.Web/Views/Account/Profile.cshtml | 33 +++++
.../ExamTemplate.Web/Views/Account/Register.cshtml | 27 ++++
.../Web/ExamTemplate.Web/Views/Home/Index.cshtml | 8 ++
.../Web/ExamTemplate.Web/Views/Shared/Error.cshtml | 25 ++++
.../Views/Shared/ErrorNotFound.cshtml | 10 ++
.../Views/Shared/_FooterContent.cshtml | 8 ++
.../ExamTemplate.Web/Views/Shared/_Layout.cshtml | 25 ++++
.../ExamTemplate.Web/Views/Shared/_Navbar.cshtml | 31 +++++
.../Web/ExamTemplate.Web/Views/_ViewImports.cshtml | 5 +
.../Web/ExamTemplate.Web/Views/_ViewStart.cshtml | 3 +
ExamTemplate/Web/ExamTemplate.Web/appsettings.json | 18 +++
.../Web/ExamTemplate.Web/wwwroot/css/site.css | 79 +++++++++++
.../Web/ExamTemplate.Web/wwwroot/css/styles.css | 143 ++++++++++++++++++++
.../Web/ExamTemplate.Web/wwwroot/favicon.ico | Bin 0 -> 32038 bytes
ExamTemplate/Web/Models/BaseWebModel.cs | 9 --
ExamTemplate/Web/Models/ErrorViewModel.cs | 9 --
ExamTemplate/Web/Models/User/EditUserWebModel.cs | 19 ---
ExamTemplate/Web/Models/User/LoginUserWebModel.cs | 15 ---
.../Web/Models/User/RegisterUserWebModel.cs | 23 ----
ExamTemplate/Web/Models/User/UserWebModel.cs | 9 --
ExamTemplate/Web/Program.cs | 20 ---
ExamTemplate/Web/Properties/launchSettings.json | 27 ----
ExamTemplate/Web/Startup.cs | 134 -------------------
ExamTemplate/Web/Views/Account/Edit.cshtml | 20 ---
ExamTemplate/Web/Views/Account/Login.cshtml | 23 ----
ExamTemplate/Web/Views/Account/Profile.cshtml | 33 -----
ExamTemplate/Web/Views/Account/Register.cshtml | 27 ----
ExamTemplate/Web/Views/Home/Index.cshtml | 8 --
ExamTemplate/Web/Views/Shared/Error.cshtml | 25 ----
ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml | 10 --
.../Web/Views/Shared/_FooterContent.cshtml | 8 --
ExamTemplate/Web/Views/Shared/_Layout.cshtml | 25 ----
ExamTemplate/Web/Views/Shared/_Navbar.cshtml | 31 -----
ExamTemplate/Web/Views/_ViewImports.cshtml | 5 -
ExamTemplate/Web/Views/_ViewStart.cshtml | 3 -
ExamTemplate/Web/Web.csproj | 18 ---
ExamTemplate/Web/appsettings.json | 18 ---
ExamTemplate/Web/wwwroot/css/site.css | 79 -----------
ExamTemplate/Web/wwwroot/css/styles.css | 143 --------------------
ExamTemplate/Web/wwwroot/favicon.ico | Bin 32038 -> 0 bytes
59 files changed, 947 insertions(+), 938 deletions(-)
delete mode 100644 ExamTemplate/Web/Configurations/ControllerUserMappings.cs
delete mode 100644 ExamTemplate/Web/Controllers/AccountController.cs
delete mode 100644 ExamTemplate/Web/Controllers/HomeController.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web.Models/BaseWebModel.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web.Models/ErrorViewModel.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web.Models/ExamTemplate.Web.Models.csproj
create mode 100644 ExamTemplate/Web/ExamTemplate.Web.Models/User/EditUserWebModel.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web.Models/User/LoginUserWebModel.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web.Models/User/RegisterUserWebModel.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web.Models/User/UserWebModel.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Configurations/ControllerUserMappings.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Controllers/AccountController.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Controllers/HomeController.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/ExamTemplate.Web.csproj
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Program.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Properties/launchSettings.json
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Startup.cs
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Account/Edit.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Account/Login.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Account/Profile.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Account/Register.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Home/Index.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Shared/Error.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Shared/ErrorNotFound.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_FooterContent.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_Layout.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_Navbar.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/_ViewImports.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/Views/_ViewStart.cshtml
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/appsettings.json
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/wwwroot/css/site.css
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/wwwroot/css/styles.css
create mode 100644 ExamTemplate/Web/ExamTemplate.Web/wwwroot/favicon.ico
delete mode 100644 ExamTemplate/Web/Models/BaseWebModel.cs
delete mode 100644 ExamTemplate/Web/Models/ErrorViewModel.cs
delete mode 100644 ExamTemplate/Web/Models/User/EditUserWebModel.cs
delete mode 100644 ExamTemplate/Web/Models/User/LoginUserWebModel.cs
delete mode 100644 ExamTemplate/Web/Models/User/RegisterUserWebModel.cs
delete mode 100644 ExamTemplate/Web/Models/User/UserWebModel.cs
delete mode 100644 ExamTemplate/Web/Program.cs
delete mode 100644 ExamTemplate/Web/Properties/launchSettings.json
delete mode 100644 ExamTemplate/Web/Startup.cs
delete mode 100644 ExamTemplate/Web/Views/Account/Edit.cshtml
delete mode 100644 ExamTemplate/Web/Views/Account/Login.cshtml
delete mode 100644 ExamTemplate/Web/Views/Account/Profile.cshtml
delete mode 100644 ExamTemplate/Web/Views/Account/Register.cshtml
delete mode 100644 ExamTemplate/Web/Views/Home/Index.cshtml
delete mode 100644 ExamTemplate/Web/Views/Shared/Error.cshtml
delete mode 100644 ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml
delete mode 100644 ExamTemplate/Web/Views/Shared/_FooterContent.cshtml
delete mode 100644 ExamTemplate/Web/Views/Shared/_Layout.cshtml
delete mode 100644 ExamTemplate/Web/Views/Shared/_Navbar.cshtml
delete mode 100644 ExamTemplate/Web/Views/_ViewImports.cshtml
delete mode 100644 ExamTemplate/Web/Views/_ViewStart.cshtml
delete mode 100644 ExamTemplate/Web/Web.csproj
delete mode 100644 ExamTemplate/Web/appsettings.json
delete mode 100644 ExamTemplate/Web/wwwroot/css/site.css
delete mode 100644 ExamTemplate/Web/wwwroot/css/styles.css
delete mode 100644 ExamTemplate/Web/wwwroot/favicon.ico
(limited to 'ExamTemplate/Web')
diff --git a/ExamTemplate/Web/Configurations/ControllerUserMappings.cs b/ExamTemplate/Web/Configurations/ControllerUserMappings.cs
deleted file mode 100644
index 05c57e2..0000000
--- a/ExamTemplate/Web/Configurations/ControllerUserMappings.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using AutoMapper;
-using ExamTemplate.Services.Models.User;
-using ExamTemplate.Web.Models.User;
-
-namespace ExamTemplate.Services.Configurations
-{
- public class ControllerUserMappings : Profile
- {
- public ControllerUserMappings()
- {
- CreateMap();
- CreateMap();
- CreateMap();
- CreateMap();
- CreateMap();
- }
- }
-}
diff --git a/ExamTemplate/Web/Controllers/AccountController.cs b/ExamTemplate/Web/Controllers/AccountController.cs
deleted file mode 100644
index 2c2eb32..0000000
--- a/ExamTemplate/Web/Controllers/AccountController.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using ExamTemplate.Services.Interfaces;
-using Microsoft.AspNetCore.Mvc;
-using ExamTemplate.Web.Models.User;
-using AutoMapper;
-using ExamTemplate.Services.Models.User;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-
-namespace ExamTemplate.Web.Controllers
-{
- [Authorize]
- public class AccountController : Controller
- {
- private readonly IMapper _autoMapper;
- private readonly IUserService _userService;
-
- public AccountController(IMapper autoMapper, IUserService userService)
- {
- this._autoMapper = autoMapper;
- this._userService = userService;
- }
-
- [HttpGet]
- [AllowAnonymous]
- public IActionResult Register()
- {
- return View();
- }
-
- [HttpPost]
- [AllowAnonymous]
- public async Task Register(RegisterUserWebModel registerUserWebModel)
- {
- if (!ModelState.IsValid)
- return View(registerUserWebModel);
-
- RegisterUserServiceModel registerUserServiceModel = this._autoMapper.Map(registerUserWebModel);
-
- bool result = await this._userService.RegisterUserAsync(registerUserServiceModel);
-
- if (result)
- return await this.Login(new LoginUserWebModel {
- Username = registerUserServiceModel.Username,
- Password = registerUserServiceModel.Password
- });
- else
- return View(registerUserWebModel);
- }
-
- [HttpGet]
- [AllowAnonymous]
- public IActionResult Login()
- {
- return View();
- }
-
- [HttpPost]
- [AllowAnonymous]
- public async Task Login(LoginUserWebModel loginUserWebModel)
- {
- if (!ModelState.IsValid)
- return View(loginUserWebModel);
-
- LoginUserServiceModel loginUserServiceModel = this._autoMapper.Map(loginUserWebModel);
-
- bool result = await this._userService.LoginUserAsync(loginUserServiceModel);
-
- if (result)
- return RedirectToAction("Index", "Home");
- else
- return View(loginUserWebModel);
- }
-
- [HttpPost]
- public async Task Logout()
- {
- await this._userService.LogoutAsync();
-
- return RedirectToAction("Login");
- }
-
- [HttpGet]
- [AllowAnonymous]
- public async Task Profile(string username)
- {
- UserServiceModel userServiceModel = await this._userService.GetUserByUsernameAsync(username);
-
- if (userServiceModel == default(UserServiceModel))
- return RedirectToAction("ErrorNotFound", "Home");
-
- UserWebModel userWebModel = this._autoMapper.Map(userServiceModel);
-
- return View(userWebModel);
- }
-
- [HttpGet]
- public async Task Edit()
- {
- UserServiceModel userServiceModel = await this._userService.GetUserByClaimsAsync(this.HttpContext.User);
-
- if (userServiceModel == default(UserServiceModel))
- return RedirectToAction("ErrorNotFound", "Home");
-
- EditUserWebModel editUserWebModel = this._autoMapper.Map(userServiceModel);
-
- return View(editUserWebModel);
- }
-
- [HttpPost]
- public async Task Edit(EditUserWebModel editUserWebModel)
- {
- if (!ModelState.IsValid)
- return View(editUserWebModel);
-
- if (!this._userService.IsSignedIn(HttpContext.User))
- return RedirectToAction("Login");
-
- UserServiceModel loggedInUser = await this._userService.GetUserByClaimsAsync(HttpContext.User);
-
- UserServiceModel userServiceModel = this._autoMapper.Map(editUserWebModel);
- bool result = await this._userService.EditUserAsync(HttpContext.User, userServiceModel);
-
- if (result)
- {
- if (loggedInUser.Username != editUserWebModel.Username)
- await this._userService.LogoutAsync();
-
- return RedirectToAction("Profile", new { username = editUserWebModel.Username });
- }
- else
- return RedirectToAction("Profile", new { username = loggedInUser.Username });
- }
-
- [HttpPost]
- public async Task Delete()
- {
- await this._userService.LogoutAsync();
- bool result = await this._userService.DeleteUserAsync(HttpContext.User);
-
- if (result)
- return RedirectToAction("Login");
- else
- return RedirectToAction("Index", "Home");
- }
- }
-}
diff --git a/ExamTemplate/Web/Controllers/HomeController.cs b/ExamTemplate/Web/Controllers/HomeController.cs
deleted file mode 100644
index d9cfc45..0000000
--- a/ExamTemplate/Web/Controllers/HomeController.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Diagnostics;
-using ExamTemplate.Web.Models;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Logging;
-
-namespace ExamTemplate.Web.Controllers
-{
- public class HomeController : Controller
- {
- private readonly ILogger _logger;
-
- public HomeController(ILogger logger)
- {
- _logger = logger;
- }
-
- public IActionResult Index()
- {
- return View();
- }
-
- [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
- public IActionResult Error()
- {
- return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
- }
-
- public IActionResult ErrorNotFound()
- {
- return View();
- }
- }
-}
diff --git a/ExamTemplate/Web/ExamTemplate.Web.Models/BaseWebModel.cs b/ExamTemplate/Web/ExamTemplate.Web.Models/BaseWebModel.cs
new file mode 100644
index 0000000..1b662af
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web.Models/BaseWebModel.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace ExamTemplate.Web.Models
+{
+ public abstract class BaseWebModel
+ {
+ public Guid Id { get; set; }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web.Models/ErrorViewModel.cs b/ExamTemplate/Web/ExamTemplate.Web.Models/ErrorViewModel.cs
new file mode 100644
index 0000000..af40d4c
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web.Models/ErrorViewModel.cs
@@ -0,0 +1,9 @@
+namespace ExamTemplate.Web.Models
+{
+ public class ErrorViewModel
+ {
+ public string RequestId { get; set; }
+
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web.Models/ExamTemplate.Web.Models.csproj b/ExamTemplate/Web/ExamTemplate.Web.Models/ExamTemplate.Web.Models.csproj
new file mode 100644
index 0000000..563e6f9
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web.Models/ExamTemplate.Web.Models.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net5.0
+
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web.Models/User/EditUserWebModel.cs b/ExamTemplate/Web/ExamTemplate.Web.Models/User/EditUserWebModel.cs
new file mode 100644
index 0000000..119a585
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web.Models/User/EditUserWebModel.cs
@@ -0,0 +1,19 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace ExamTemplate.Web.Models.User
+{
+ public class EditUserWebModel
+ {
+ [Required]
+ [MinLength(1)]
+ public string FirstName { get; set; }
+
+ [Required]
+ [MinLength(1)]
+ public string LastName { get; set; }
+
+ [Required]
+ [MinLength(1)]
+ public string Username { get; set; }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web.Models/User/LoginUserWebModel.cs b/ExamTemplate/Web/ExamTemplate.Web.Models/User/LoginUserWebModel.cs
new file mode 100644
index 0000000..0f4ef73
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web.Models/User/LoginUserWebModel.cs
@@ -0,0 +1,15 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace ExamTemplate.Web.Models.User
+{
+ public class LoginUserWebModel
+ {
+ [Required]
+ [MinLength(1)]
+ public string Username { get; set; }
+
+ [Required]
+ [MinLength(1)]
+ public string Password { get; set; }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web.Models/User/RegisterUserWebModel.cs b/ExamTemplate/Web/ExamTemplate.Web.Models/User/RegisterUserWebModel.cs
new file mode 100644
index 0000000..c443dd2
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web.Models/User/RegisterUserWebModel.cs
@@ -0,0 +1,23 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace ExamTemplate.Web.Models.User
+{
+ public class RegisterUserWebModel
+ {
+ [Required]
+ [MinLength(1)]
+ public string FirstName { get; set; }
+
+ [Required]
+ [MinLength(1)]
+ public string LastName { get; set; }
+
+ [Required]
+ [MinLength(1)]
+ public string Username { get; set; }
+
+ [Required]
+ [MinLength(3)]
+ public string Password { get; set; }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web.Models/User/UserWebModel.cs b/ExamTemplate/Web/ExamTemplate.Web.Models/User/UserWebModel.cs
new file mode 100644
index 0000000..af8d6c7
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web.Models/User/UserWebModel.cs
@@ -0,0 +1,9 @@
+namespace ExamTemplate.Web.Models.User
+{
+ public class UserWebModel
+ {
+ public string FirstName { get; set; }
+ public string LastName { get; set; }
+ public string Username { get; set; }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Configurations/ControllerUserMappings.cs b/ExamTemplate/Web/ExamTemplate.Web/Configurations/ControllerUserMappings.cs
new file mode 100644
index 0000000..05c57e2
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Configurations/ControllerUserMappings.cs
@@ -0,0 +1,18 @@
+using AutoMapper;
+using ExamTemplate.Services.Models.User;
+using ExamTemplate.Web.Models.User;
+
+namespace ExamTemplate.Services.Configurations
+{
+ public class ControllerUserMappings : Profile
+ {
+ public ControllerUserMappings()
+ {
+ CreateMap();
+ CreateMap();
+ CreateMap();
+ CreateMap();
+ CreateMap();
+ }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Controllers/AccountController.cs b/ExamTemplate/Web/ExamTemplate.Web/Controllers/AccountController.cs
new file mode 100644
index 0000000..2c2eb32
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Controllers/AccountController.cs
@@ -0,0 +1,146 @@
+using ExamTemplate.Services.Interfaces;
+using Microsoft.AspNetCore.Mvc;
+using ExamTemplate.Web.Models.User;
+using AutoMapper;
+using ExamTemplate.Services.Models.User;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization;
+
+namespace ExamTemplate.Web.Controllers
+{
+ [Authorize]
+ public class AccountController : Controller
+ {
+ private readonly IMapper _autoMapper;
+ private readonly IUserService _userService;
+
+ public AccountController(IMapper autoMapper, IUserService userService)
+ {
+ this._autoMapper = autoMapper;
+ this._userService = userService;
+ }
+
+ [HttpGet]
+ [AllowAnonymous]
+ public IActionResult Register()
+ {
+ return View();
+ }
+
+ [HttpPost]
+ [AllowAnonymous]
+ public async Task Register(RegisterUserWebModel registerUserWebModel)
+ {
+ if (!ModelState.IsValid)
+ return View(registerUserWebModel);
+
+ RegisterUserServiceModel registerUserServiceModel = this._autoMapper.Map(registerUserWebModel);
+
+ bool result = await this._userService.RegisterUserAsync(registerUserServiceModel);
+
+ if (result)
+ return await this.Login(new LoginUserWebModel {
+ Username = registerUserServiceModel.Username,
+ Password = registerUserServiceModel.Password
+ });
+ else
+ return View(registerUserWebModel);
+ }
+
+ [HttpGet]
+ [AllowAnonymous]
+ public IActionResult Login()
+ {
+ return View();
+ }
+
+ [HttpPost]
+ [AllowAnonymous]
+ public async Task Login(LoginUserWebModel loginUserWebModel)
+ {
+ if (!ModelState.IsValid)
+ return View(loginUserWebModel);
+
+ LoginUserServiceModel loginUserServiceModel = this._autoMapper.Map(loginUserWebModel);
+
+ bool result = await this._userService.LoginUserAsync(loginUserServiceModel);
+
+ if (result)
+ return RedirectToAction("Index", "Home");
+ else
+ return View(loginUserWebModel);
+ }
+
+ [HttpPost]
+ public async Task Logout()
+ {
+ await this._userService.LogoutAsync();
+
+ return RedirectToAction("Login");
+ }
+
+ [HttpGet]
+ [AllowAnonymous]
+ public async Task Profile(string username)
+ {
+ UserServiceModel userServiceModel = await this._userService.GetUserByUsernameAsync(username);
+
+ if (userServiceModel == default(UserServiceModel))
+ return RedirectToAction("ErrorNotFound", "Home");
+
+ UserWebModel userWebModel = this._autoMapper.Map(userServiceModel);
+
+ return View(userWebModel);
+ }
+
+ [HttpGet]
+ public async Task Edit()
+ {
+ UserServiceModel userServiceModel = await this._userService.GetUserByClaimsAsync(this.HttpContext.User);
+
+ if (userServiceModel == default(UserServiceModel))
+ return RedirectToAction("ErrorNotFound", "Home");
+
+ EditUserWebModel editUserWebModel = this._autoMapper.Map(userServiceModel);
+
+ return View(editUserWebModel);
+ }
+
+ [HttpPost]
+ public async Task Edit(EditUserWebModel editUserWebModel)
+ {
+ if (!ModelState.IsValid)
+ return View(editUserWebModel);
+
+ if (!this._userService.IsSignedIn(HttpContext.User))
+ return RedirectToAction("Login");
+
+ UserServiceModel loggedInUser = await this._userService.GetUserByClaimsAsync(HttpContext.User);
+
+ UserServiceModel userServiceModel = this._autoMapper.Map(editUserWebModel);
+ bool result = await this._userService.EditUserAsync(HttpContext.User, userServiceModel);
+
+ if (result)
+ {
+ if (loggedInUser.Username != editUserWebModel.Username)
+ await this._userService.LogoutAsync();
+
+ return RedirectToAction("Profile", new { username = editUserWebModel.Username });
+ }
+ else
+ return RedirectToAction("Profile", new { username = loggedInUser.Username });
+ }
+
+ [HttpPost]
+ public async Task Delete()
+ {
+ await this._userService.LogoutAsync();
+ bool result = await this._userService.DeleteUserAsync(HttpContext.User);
+
+ if (result)
+ return RedirectToAction("Login");
+ else
+ return RedirectToAction("Index", "Home");
+ }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Controllers/HomeController.cs b/ExamTemplate/Web/ExamTemplate.Web/Controllers/HomeController.cs
new file mode 100644
index 0000000..d9cfc45
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Controllers/HomeController.cs
@@ -0,0 +1,33 @@
+using System.Diagnostics;
+using ExamTemplate.Web.Models;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace ExamTemplate.Web.Controllers
+{
+ public class HomeController : Controller
+ {
+ private readonly ILogger _logger;
+
+ public HomeController(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ public IActionResult Index()
+ {
+ return View();
+ }
+
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
+ public IActionResult Error()
+ {
+ return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
+ }
+
+ public IActionResult ErrorNotFound()
+ {
+ return View();
+ }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/ExamTemplate.Web.csproj b/ExamTemplate/Web/ExamTemplate.Web/ExamTemplate.Web.csproj
new file mode 100644
index 0000000..d2c2de4
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/ExamTemplate.Web.csproj
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ net5.0
+
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Program.cs b/ExamTemplate/Web/ExamTemplate.Web/Program.cs
new file mode 100644
index 0000000..be33374
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Program.cs
@@ -0,0 +1,20 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+
+namespace ExamTemplate.Web
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateHostBuilder(args).Build().Run();
+ }
+
+ public static IHostBuilder CreateHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup();
+ });
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Properties/launchSettings.json b/ExamTemplate/Web/ExamTemplate.Web/Properties/launchSettings.json
new file mode 100644
index 0000000..080115b
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Properties/launchSettings.json
@@ -0,0 +1,27 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:36205",
+ "sslPort": 44322
+ }
+ },
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "Web": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "applicationUrl": "http://localhost:5000",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Startup.cs b/ExamTemplate/Web/ExamTemplate.Web/Startup.cs
new file mode 100644
index 0000000..c18bca6
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Startup.cs
@@ -0,0 +1,134 @@
+using System;
+using System.Linq;
+using ExamTemplate.Common;
+using ExamTemplate.Data;
+using ExamTemplate.Data.Models;
+using ExamTemplate.Services.Services;
+using ExamTemplate.Services.Interfaces;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+
+namespace ExamTemplate.Web
+{
+ public class Startup
+ {
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddControllersWithViews();
+ services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
+
+ /*
+ * Dependency Injection configuration
+ */
+
+ services.AddTransient(options =>
+ new CloudinaryService(
+ cloudName: this.Configuration.GetSection("Cloud").GetSection("cloudName").Value,
+ apiKey: this.Configuration.GetSection("Cloud").GetSection("apiKey").Value,
+ apiSecret: this.Configuration.GetSection("Cloud").GetSection("apiSecret").Value));
+ services.AddTransient();
+
+ /*
+ * Database configuration
+ */
+
+ services.AddDbContext(options =>
+ options.UseNpgsql(this.Configuration.GetConnectionString("LocalDBConnection")));
+
+ // Needed for SignInManager and UserManager
+ services.AddIdentity>(options =>
+ {
+ options.SignIn.RequireConfirmedAccount = false;
+
+ // Password settings
+ options.Password.RequireDigit = false;
+ options.Password.RequireLowercase = false;
+ options.Password.RequireNonAlphanumeric = false;
+ options.Password.RequireUppercase = false;
+ options.Password.RequiredLength = 3;
+ options.Password.RequiredUniqueChars = 0;
+ }).AddRoles>()
+ .AddEntityFrameworkStores();
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+ else
+ {
+ app.UseExceptionHandler("/Home/Error");
+ // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
+ app.UseHsts();
+ }
+
+ app.UseStaticFiles();
+
+ app.UseRouting();
+
+ app.UseAuthentication();
+ app.UseAuthorization();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllerRoute(
+ name: "default",
+ pattern: "{controller=Home}/{action=Index}/{id?}");
+ endpoints.MapFallbackToController("ErrorNotFound", "Home");
+ });
+
+ /*
+ * Make sure that the database is migrated
+ * and that the User and Admin role exist in database
+ */
+
+ using var serviceScope = app.ApplicationServices.CreateScope();
+ using var dbContext = serviceScope.ServiceProvider.GetRequiredService();
+
+ dbContext.Database.Migrate();
+
+ var roleManager = (RoleManager>)serviceScope.ServiceProvider.GetService(typeof(RoleManager>));
+ foreach (string name in RoleConst.GetAllNames())
+ {
+ if (!dbContext.Roles.Any(x => x.Name == name))
+ {
+ IdentityRole role = new IdentityRole() { Name = name };
+ roleManager.CreateAsync(role).Wait();
+ }
+ }
+
+ /* If you want to create some custom database values at startup
+ * uncomment the following code
+ * and replace OBJCONST_ with your static class with constants (e.g. RoleConst)
+ * replace OBJS_ with the name of the DbSet of your database model (e.g. Roles)
+ * replace OBJ_ with the name of your database model (e.g. Role)
+
+ foreach (string name in OBJCONST_.GetAllNames())
+ {
+ if (!dbContext.OBJS_.Any(x => x.Name == name))
+ {
+ var entity = new OBJ_() { Id = Guid.NewGuid(), Name = name };
+ dbContext.OBJS_.Add(entity);
+ dbContext.SaveChanges();
+ }
+ }
+ */
+ }
+ }
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Edit.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Edit.cshtml
new file mode 100644
index 0000000..a088742
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Edit.cshtml
@@ -0,0 +1,20 @@
+@model EditUserWebModel
+@{
+ ViewData["Title"] = "Edit Profile";
+}
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Login.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Login.cshtml
new file mode 100644
index 0000000..daa3f3e
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Login.cshtml
@@ -0,0 +1,23 @@
+@model LoginUserWebModel
+@{
+ ViewData["Title"] = "Login";
+}
+
+
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Profile.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Profile.cshtml
new file mode 100644
index 0000000..33fc882
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Profile.cshtml
@@ -0,0 +1,33 @@
+@using Microsoft.AspNetCore.Identity
+
+@inject SignInManager SignInManager
+@inject UserManager UserManager
+
+@model UserWebModel
+@{
+ ViewData["Title"] = Model.Username + "'s Profile";
+}
+
+
+
+ @Model.FirstName @Model.LastName
+
+
+ @Model.Username
+
+ @if (SignInManager.IsSignedIn(User))
+ {
+ @if(UserManager.GetUserName(User) == Model.Username)
+ {
+
+
+
+
+
+ }
+ }
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Register.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Register.cshtml
new file mode 100644
index 0000000..e436d72
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Account/Register.cshtml
@@ -0,0 +1,27 @@
+@model RegisterUserWebModel
+@{
+ ViewData["Title"] = "Register";
+}
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Home/Index.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Home/Index.cshtml
new file mode 100644
index 0000000..56ea950
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Home/Index.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewData["Title"] = "Home";
+}
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/Error.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/Error.cshtml
new file mode 100644
index 0000000..5a7ce95
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/Error.cshtml
@@ -0,0 +1,25 @@
+@model ErrorViewModel
+@{
+ ViewData["Title"] = "Error";
+}
+
+Error.
+An error occurred while processing your request.
+
+@if (Model.ShowRequestId)
+{
+
+ Request ID: @Model.RequestId
+
+}
+
+Development Mode
+
+ Swapping to Development environment will display more detailed information about the error that occurred.
+
+
+ The Development environment shouldn't be enabled for deployed applications.
+ It can result in displaying sensitive information from exceptions to end users.
+ For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
+ and restarting the app.
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/ErrorNotFound.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/ErrorNotFound.cshtml
new file mode 100644
index 0000000..39fc5ca
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/ErrorNotFound.cshtml
@@ -0,0 +1,10 @@
+@{
+ ViewData["Title"] = "404: Not found!";
+}
+
+
+ 404: Not found!
+
+
+ The page you're looking for couldn't be found!
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_FooterContent.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_FooterContent.cshtml
new file mode 100644
index 0000000..60a21aa
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_FooterContent.cshtml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_Layout.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_Layout.cshtml
new file mode 100644
index 0000000..dd7bf82
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_Layout.cshtml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ @ViewData["Title"]
+
+
+
+
+
+
+
+
+ @RenderBody()
+
+
+
+
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_Navbar.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_Navbar.cshtml
new file mode 100644
index 0000000..0ec5c4d
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/Shared/_Navbar.cshtml
@@ -0,0 +1,31 @@
+@using Microsoft.AspNetCore.Identity
+
+@inject SignInManager SignInManager
+@inject UserManager UserManager
+
+
+
+
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/_ViewImports.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/_ViewImports.cshtml
new file mode 100644
index 0000000..18502e4
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/_ViewImports.cshtml
@@ -0,0 +1,5 @@
+@using ExamTemplate.Web
+@using ExamTemplate.Web.Models
+@using ExamTemplate.Web.Models.User
+@using ExamTemplate.Data.Models
+@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
diff --git a/ExamTemplate/Web/ExamTemplate.Web/Views/_ViewStart.cshtml b/ExamTemplate/Web/ExamTemplate.Web/Views/_ViewStart.cshtml
new file mode 100644
index 0000000..3a04d05
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/appsettings.json b/ExamTemplate/Web/ExamTemplate.Web/appsettings.json
new file mode 100644
index 0000000..f1b58be
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/appsettings.json
@@ -0,0 +1,18 @@
+{
+ "ConnectionStrings": {
+ "LocalDBConnection": "Server=localhost;Port=5432;Database=TemplateContext;User Id=;Password=;"
+ },
+ "Cloud": {
+ "cloudName": "ExamTemplate",
+ "apiKey": "",
+ "apiSecret": ""
+ },
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ },
+ "AllowedHosts": "*"
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/wwwroot/css/site.css b/ExamTemplate/Web/ExamTemplate.Web/wwwroot/css/site.css
new file mode 100644
index 0000000..5923427
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/wwwroot/css/site.css
@@ -0,0 +1,79 @@
+/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
+for details on configuring this project to bundle and minify static web assets. */
+
+a.navbar-brand {
+ white-space: normal;
+ text-align: center;
+ word-break: break-all;
+}
+
+/* Provide sufficient contrast against white background */
+a {
+ color: #0366d6;
+}
+
+.btn-primary {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+}
+
+.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+}
+
+/* Sticky footer styles
+-------------------------------------------------- */
+html {
+ font-size: 14px;
+}
+@media (min-width: 768px) {
+ html {
+ font-size: 16px;
+ }
+}
+
+.border-top {
+ border-top: 1px solid #e5e5e5;
+}
+.border-bottom {
+ border-bottom: 1px solid #e5e5e5;
+}
+
+.box-shadow {
+ box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
+}
+
+button.accept-policy {
+ font-size: 1rem;
+ line-height: inherit;
+}
+
+/* Sticky footer styles
+-------------------------------------------------- */
+html {
+ position: relative;
+ min-height: 100%;
+ line-height: 1.15;
+}
+
+body {
+ min-height: 100vh;
+ margin: 0;
+ font-size: 1.15em;
+ background-color: white;
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
+}
+
+/* The following is kinda dirty, that's why it's separated */
+
+body {
+ display: flex;
+ flex-direction: column;
+}
+
+body > main {
+ flex: 1;
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/wwwroot/css/styles.css b/ExamTemplate/Web/ExamTemplate.Web/wwwroot/css/styles.css
new file mode 100644
index 0000000..e7fc7b3
--- /dev/null
+++ b/ExamTemplate/Web/ExamTemplate.Web/wwwroot/css/styles.css
@@ -0,0 +1,143 @@
+
+/* Change the maximum width of content (stuff inside pages and navbar),
+ * depending on width of browser window.
+ * Configuration copied from default Bootstrap
+ */
+
+@media (min-width: 576px) {
+ :root {
+ --max-content-width: 540px;
+ }
+}
+
+@media (min-width: 768px) {
+ :root {
+ --max-content-width: 720px;
+ }
+}
+
+@media (min-width: 992px) {
+ :root {
+ --max-content-width: 960px;
+ }
+}
+
+@media (min-width: 1200px) {
+ :root {
+ --max-content-width: 1140px;
+ }
+}
+
+/* Main */
+
+.main {
+ width: 100%;
+ height: 100%;
+}
+
+ /* Stuff that you need in the middle portion
+ * of the screen (like the stuff inside the
+ * navbar and footer) should be inside
+ * an element with this tag
+ */
+.middle-content-container {
+ max-width: var(--max-content-width);
+ margin-left: auto;
+ margin-right: auto;
+}
+
+/* Navbar and footer */
+
+.navbar, .footer-content {
+ width: 100%;
+ min-height: 45px;
+
+ padding-top: 8px;
+ padding-bottom: 8px;
+
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.navbar section > :not(*:first-child) {
+ padding-left: 5px;
+}
+
+.navbar section > :not(*:last-child) {
+ padding-right: 5px;
+}
+
+.navbar a {
+ text-decoration: none;
+ color: #343a40;
+}
+
+.navbar a:hover {
+ color: black;
+}
+
+.navbar-contents {
+ width: 100%;
+ display: flex;
+ box-sizing: border-box;
+}
+
+.navbar-contents > * {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+/* Forms */
+
+form {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ width: fit-content;
+}
+
+.main > div > form {
+ margin-top: 10px;
+}
+
+.main > div > form:first-child {
+ width: 100%;
+ max-width: 300px;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+form > * {
+ width: 100%;
+ box-sizing: border-box;
+}
+
+input {
+ margin: 5px;
+ padding: 9px;
+ border: 1px solid darkgrey;
+ border-radius: 4px;
+}
+
+input[type="submit"] {
+ color: white;
+ background-color: black;
+}
+
+input[type="submit"]:hover {
+ cursor: pointer;
+}
+
+.form-error {
+ font-size: 0.8em;
+ color: red;
+}
+
+/* Other general stuff */
+
+.flex-spacer {
+ flex: 1;
+}
diff --git a/ExamTemplate/Web/ExamTemplate.Web/wwwroot/favicon.ico b/ExamTemplate/Web/ExamTemplate.Web/wwwroot/favicon.ico
new file mode 100644
index 0000000..a3a7999
Binary files /dev/null and b/ExamTemplate/Web/ExamTemplate.Web/wwwroot/favicon.ico differ
diff --git a/ExamTemplate/Web/Models/BaseWebModel.cs b/ExamTemplate/Web/Models/BaseWebModel.cs
deleted file mode 100644
index 1b662af..0000000
--- a/ExamTemplate/Web/Models/BaseWebModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System;
-
-namespace ExamTemplate.Web.Models
-{
- public abstract class BaseWebModel
- {
- public Guid Id { get; set; }
- }
-}
diff --git a/ExamTemplate/Web/Models/ErrorViewModel.cs b/ExamTemplate/Web/Models/ErrorViewModel.cs
deleted file mode 100644
index af40d4c..0000000
--- a/ExamTemplate/Web/Models/ErrorViewModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace ExamTemplate.Web.Models
-{
- public class ErrorViewModel
- {
- public string RequestId { get; set; }
-
- public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
- }
-}
diff --git a/ExamTemplate/Web/Models/User/EditUserWebModel.cs b/ExamTemplate/Web/Models/User/EditUserWebModel.cs
deleted file mode 100644
index 119a585..0000000
--- a/ExamTemplate/Web/Models/User/EditUserWebModel.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace ExamTemplate.Web.Models.User
-{
- public class EditUserWebModel
- {
- [Required]
- [MinLength(1)]
- public string FirstName { get; set; }
-
- [Required]
- [MinLength(1)]
- public string LastName { get; set; }
-
- [Required]
- [MinLength(1)]
- public string Username { get; set; }
- }
-}
diff --git a/ExamTemplate/Web/Models/User/LoginUserWebModel.cs b/ExamTemplate/Web/Models/User/LoginUserWebModel.cs
deleted file mode 100644
index 0f4ef73..0000000
--- a/ExamTemplate/Web/Models/User/LoginUserWebModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace ExamTemplate.Web.Models.User
-{
- public class LoginUserWebModel
- {
- [Required]
- [MinLength(1)]
- public string Username { get; set; }
-
- [Required]
- [MinLength(1)]
- public string Password { get; set; }
- }
-}
diff --git a/ExamTemplate/Web/Models/User/RegisterUserWebModel.cs b/ExamTemplate/Web/Models/User/RegisterUserWebModel.cs
deleted file mode 100644
index c443dd2..0000000
--- a/ExamTemplate/Web/Models/User/RegisterUserWebModel.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace ExamTemplate.Web.Models.User
-{
- public class RegisterUserWebModel
- {
- [Required]
- [MinLength(1)]
- public string FirstName { get; set; }
-
- [Required]
- [MinLength(1)]
- public string LastName { get; set; }
-
- [Required]
- [MinLength(1)]
- public string Username { get; set; }
-
- [Required]
- [MinLength(3)]
- public string Password { get; set; }
- }
-}
diff --git a/ExamTemplate/Web/Models/User/UserWebModel.cs b/ExamTemplate/Web/Models/User/UserWebModel.cs
deleted file mode 100644
index af8d6c7..0000000
--- a/ExamTemplate/Web/Models/User/UserWebModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace ExamTemplate.Web.Models.User
-{
- public class UserWebModel
- {
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Username { get; set; }
- }
-}
diff --git a/ExamTemplate/Web/Program.cs b/ExamTemplate/Web/Program.cs
deleted file mode 100644
index be33374..0000000
--- a/ExamTemplate/Web/Program.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Hosting;
-
-namespace ExamTemplate.Web
-{
- public class Program
- {
- public static void Main(string[] args)
- {
- CreateHostBuilder(args).Build().Run();
- }
-
- public static IHostBuilder CreateHostBuilder(string[] args) =>
- Host.CreateDefaultBuilder(args)
- .ConfigureWebHostDefaults(webBuilder =>
- {
- webBuilder.UseStartup();
- });
- }
-}
diff --git a/ExamTemplate/Web/Properties/launchSettings.json b/ExamTemplate/Web/Properties/launchSettings.json
deleted file mode 100644
index 080115b..0000000
--- a/ExamTemplate/Web/Properties/launchSettings.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:36205",
- "sslPort": 44322
- }
- },
- "profiles": {
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "Web": {
- "commandName": "Project",
- "launchBrowser": true,
- "applicationUrl": "http://localhost:5000",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- }
- }
-}
diff --git a/ExamTemplate/Web/Startup.cs b/ExamTemplate/Web/Startup.cs
deleted file mode 100644
index c18bca6..0000000
--- a/ExamTemplate/Web/Startup.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using System.Linq;
-using ExamTemplate.Common;
-using ExamTemplate.Data;
-using ExamTemplate.Data.Models;
-using ExamTemplate.Services.Services;
-using ExamTemplate.Services.Interfaces;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-
-namespace ExamTemplate.Web
-{
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
-
- public IConfiguration Configuration { get; }
-
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddControllersWithViews();
- services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
-
- /*
- * Dependency Injection configuration
- */
-
- services.AddTransient(options =>
- new CloudinaryService(
- cloudName: this.Configuration.GetSection("Cloud").GetSection("cloudName").Value,
- apiKey: this.Configuration.GetSection("Cloud").GetSection("apiKey").Value,
- apiSecret: this.Configuration.GetSection("Cloud").GetSection("apiSecret").Value));
- services.AddTransient();
-
- /*
- * Database configuration
- */
-
- services.AddDbContext(options =>
- options.UseNpgsql(this.Configuration.GetConnectionString("LocalDBConnection")));
-
- // Needed for SignInManager and UserManager
- services.AddIdentity>(options =>
- {
- options.SignIn.RequireConfirmedAccount = false;
-
- // Password settings
- options.Password.RequireDigit = false;
- options.Password.RequireLowercase = false;
- options.Password.RequireNonAlphanumeric = false;
- options.Password.RequireUppercase = false;
- options.Password.RequiredLength = 3;
- options.Password.RequiredUniqueChars = 0;
- }).AddRoles>()
- .AddEntityFrameworkStores();
- }
-
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
- app.UseHsts();
- }
-
- app.UseStaticFiles();
-
- app.UseRouting();
-
- app.UseAuthentication();
- app.UseAuthorization();
-
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllerRoute(
- name: "default",
- pattern: "{controller=Home}/{action=Index}/{id?}");
- endpoints.MapFallbackToController("ErrorNotFound", "Home");
- });
-
- /*
- * Make sure that the database is migrated
- * and that the User and Admin role exist in database
- */
-
- using var serviceScope = app.ApplicationServices.CreateScope();
- using var dbContext = serviceScope.ServiceProvider.GetRequiredService();
-
- dbContext.Database.Migrate();
-
- var roleManager = (RoleManager>)serviceScope.ServiceProvider.GetService(typeof(RoleManager>));
- foreach (string name in RoleConst.GetAllNames())
- {
- if (!dbContext.Roles.Any(x => x.Name == name))
- {
- IdentityRole role = new IdentityRole() { Name = name };
- roleManager.CreateAsync(role).Wait();
- }
- }
-
- /* If you want to create some custom database values at startup
- * uncomment the following code
- * and replace OBJCONST_ with your static class with constants (e.g. RoleConst)
- * replace OBJS_ with the name of the DbSet of your database model (e.g. Roles)
- * replace OBJ_ with the name of your database model (e.g. Role)
-
- foreach (string name in OBJCONST_.GetAllNames())
- {
- if (!dbContext.OBJS_.Any(x => x.Name == name))
- {
- var entity = new OBJ_() { Id = Guid.NewGuid(), Name = name };
- dbContext.OBJS_.Add(entity);
- dbContext.SaveChanges();
- }
- }
- */
- }
- }
-}
diff --git a/ExamTemplate/Web/Views/Account/Edit.cshtml b/ExamTemplate/Web/Views/Account/Edit.cshtml
deleted file mode 100644
index a088742..0000000
--- a/ExamTemplate/Web/Views/Account/Edit.cshtml
+++ /dev/null
@@ -1,20 +0,0 @@
-@model EditUserWebModel
-@{
- ViewData["Title"] = "Edit Profile";
-}
-
-
diff --git a/ExamTemplate/Web/Views/Account/Login.cshtml b/ExamTemplate/Web/Views/Account/Login.cshtml
deleted file mode 100644
index daa3f3e..0000000
--- a/ExamTemplate/Web/Views/Account/Login.cshtml
+++ /dev/null
@@ -1,23 +0,0 @@
-@model LoginUserWebModel
-@{
- ViewData["Title"] = "Login";
-}
-
-
-
-
diff --git a/ExamTemplate/Web/Views/Account/Profile.cshtml b/ExamTemplate/Web/Views/Account/Profile.cshtml
deleted file mode 100644
index 33fc882..0000000
--- a/ExamTemplate/Web/Views/Account/Profile.cshtml
+++ /dev/null
@@ -1,33 +0,0 @@
-@using Microsoft.AspNetCore.Identity
-
-@inject SignInManager SignInManager
-@inject UserManager UserManager
-
-@model UserWebModel
-@{
- ViewData["Title"] = Model.Username + "'s Profile";
-}
-
-
-
- @Model.FirstName @Model.LastName
-
-
- @Model.Username
-
- @if (SignInManager.IsSignedIn(User))
- {
- @if(UserManager.GetUserName(User) == Model.Username)
- {
-
-
-
-
-
- }
- }
-
diff --git a/ExamTemplate/Web/Views/Account/Register.cshtml b/ExamTemplate/Web/Views/Account/Register.cshtml
deleted file mode 100644
index e436d72..0000000
--- a/ExamTemplate/Web/Views/Account/Register.cshtml
+++ /dev/null
@@ -1,27 +0,0 @@
-@model RegisterUserWebModel
-@{
- ViewData["Title"] = "Register";
-}
-
-
diff --git a/ExamTemplate/Web/Views/Home/Index.cshtml b/ExamTemplate/Web/Views/Home/Index.cshtml
deleted file mode 100644
index 56ea950..0000000
--- a/ExamTemplate/Web/Views/Home/Index.cshtml
+++ /dev/null
@@ -1,8 +0,0 @@
-@{
- ViewData["Title"] = "Home";
-}
-
-
diff --git a/ExamTemplate/Web/Views/Shared/Error.cshtml b/ExamTemplate/Web/Views/Shared/Error.cshtml
deleted file mode 100644
index 5a7ce95..0000000
--- a/ExamTemplate/Web/Views/Shared/Error.cshtml
+++ /dev/null
@@ -1,25 +0,0 @@
-@model ErrorViewModel
-@{
- ViewData["Title"] = "Error";
-}
-
-Error.
-An error occurred while processing your request.
-
-@if (Model.ShowRequestId)
-{
-
- Request ID: @Model.RequestId
-
-}
-
-Development Mode
-
- Swapping to Development environment will display more detailed information about the error that occurred.
-
-
- The Development environment shouldn't be enabled for deployed applications.
- It can result in displaying sensitive information from exceptions to end users.
- For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
- and restarting the app.
-
diff --git a/ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml b/ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml
deleted file mode 100644
index 39fc5ca..0000000
--- a/ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml
+++ /dev/null
@@ -1,10 +0,0 @@
-@{
- ViewData["Title"] = "404: Not found!";
-}
-
-
- 404: Not found!
-
-
- The page you're looking for couldn't be found!
-
diff --git a/ExamTemplate/Web/Views/Shared/_FooterContent.cshtml b/ExamTemplate/Web/Views/Shared/_FooterContent.cshtml
deleted file mode 100644
index 60a21aa..0000000
--- a/ExamTemplate/Web/Views/Shared/_FooterContent.cshtml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
diff --git a/ExamTemplate/Web/Views/Shared/_Layout.cshtml b/ExamTemplate/Web/Views/Shared/_Layout.cshtml
deleted file mode 100644
index dd7bf82..0000000
--- a/ExamTemplate/Web/Views/Shared/_Layout.cshtml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
- @ViewData["Title"]
-
-
-
-
-
-
-
-
- @RenderBody()
-
-
-
-
-
-
diff --git a/ExamTemplate/Web/Views/Shared/_Navbar.cshtml b/ExamTemplate/Web/Views/Shared/_Navbar.cshtml
deleted file mode 100644
index 0ec5c4d..0000000
--- a/ExamTemplate/Web/Views/Shared/_Navbar.cshtml
+++ /dev/null
@@ -1,31 +0,0 @@
-@using Microsoft.AspNetCore.Identity
-
-@inject SignInManager SignInManager
-@inject UserManager UserManager
-
-
-
-
diff --git a/ExamTemplate/Web/Views/_ViewImports.cshtml b/ExamTemplate/Web/Views/_ViewImports.cshtml
deleted file mode 100644
index 18502e4..0000000
--- a/ExamTemplate/Web/Views/_ViewImports.cshtml
+++ /dev/null
@@ -1,5 +0,0 @@
-@using ExamTemplate.Web
-@using ExamTemplate.Web.Models
-@using ExamTemplate.Web.Models.User
-@using ExamTemplate.Data.Models
-@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
diff --git a/ExamTemplate/Web/Views/_ViewStart.cshtml b/ExamTemplate/Web/Views/_ViewStart.cshtml
deleted file mode 100644
index 3a04d05..0000000
--- a/ExamTemplate/Web/Views/_ViewStart.cshtml
+++ /dev/null
@@ -1,3 +0,0 @@
-@{
- Layout = "_Layout";
-}
diff --git a/ExamTemplate/Web/Web.csproj b/ExamTemplate/Web/Web.csproj
deleted file mode 100644
index 44c6a7a..0000000
--- a/ExamTemplate/Web/Web.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- net5.0
-
-
-
diff --git a/ExamTemplate/Web/appsettings.json b/ExamTemplate/Web/appsettings.json
deleted file mode 100644
index f1b58be..0000000
--- a/ExamTemplate/Web/appsettings.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "ConnectionStrings": {
- "LocalDBConnection": "Server=localhost;Port=5432;Database=TemplateContext;User Id=;Password=;"
- },
- "Cloud": {
- "cloudName": "ExamTemplate",
- "apiKey": "",
- "apiSecret": ""
- },
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- },
- "AllowedHosts": "*"
-}
diff --git a/ExamTemplate/Web/wwwroot/css/site.css b/ExamTemplate/Web/wwwroot/css/site.css
deleted file mode 100644
index 5923427..0000000
--- a/ExamTemplate/Web/wwwroot/css/site.css
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
-for details on configuring this project to bundle and minify static web assets. */
-
-a.navbar-brand {
- white-space: normal;
- text-align: center;
- word-break: break-all;
-}
-
-/* Provide sufficient contrast against white background */
-a {
- color: #0366d6;
-}
-
-.btn-primary {
- color: #fff;
- background-color: #1b6ec2;
- border-color: #1861ac;
-}
-
-.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
- color: #fff;
- background-color: #1b6ec2;
- border-color: #1861ac;
-}
-
-/* Sticky footer styles
--------------------------------------------------- */
-html {
- font-size: 14px;
-}
-@media (min-width: 768px) {
- html {
- font-size: 16px;
- }
-}
-
-.border-top {
- border-top: 1px solid #e5e5e5;
-}
-.border-bottom {
- border-bottom: 1px solid #e5e5e5;
-}
-
-.box-shadow {
- box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
-}
-
-button.accept-policy {
- font-size: 1rem;
- line-height: inherit;
-}
-
-/* Sticky footer styles
--------------------------------------------------- */
-html {
- position: relative;
- min-height: 100%;
- line-height: 1.15;
-}
-
-body {
- min-height: 100vh;
- margin: 0;
- font-size: 1.15em;
- background-color: white;
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
-}
-
-/* The following is kinda dirty, that's why it's separated */
-
-body {
- display: flex;
- flex-direction: column;
-}
-
-body > main {
- flex: 1;
-}
diff --git a/ExamTemplate/Web/wwwroot/css/styles.css b/ExamTemplate/Web/wwwroot/css/styles.css
deleted file mode 100644
index e7fc7b3..0000000
--- a/ExamTemplate/Web/wwwroot/css/styles.css
+++ /dev/null
@@ -1,143 +0,0 @@
-
-/* Change the maximum width of content (stuff inside pages and navbar),
- * depending on width of browser window.
- * Configuration copied from default Bootstrap
- */
-
-@media (min-width: 576px) {
- :root {
- --max-content-width: 540px;
- }
-}
-
-@media (min-width: 768px) {
- :root {
- --max-content-width: 720px;
- }
-}
-
-@media (min-width: 992px) {
- :root {
- --max-content-width: 960px;
- }
-}
-
-@media (min-width: 1200px) {
- :root {
- --max-content-width: 1140px;
- }
-}
-
-/* Main */
-
-.main {
- width: 100%;
- height: 100%;
-}
-
- /* Stuff that you need in the middle portion
- * of the screen (like the stuff inside the
- * navbar and footer) should be inside
- * an element with this tag
- */
-.middle-content-container {
- max-width: var(--max-content-width);
- margin-left: auto;
- margin-right: auto;
-}
-
-/* Navbar and footer */
-
-.navbar, .footer-content {
- width: 100%;
- min-height: 45px;
-
- padding-top: 8px;
- padding-bottom: 8px;
-
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.navbar section > :not(*:first-child) {
- padding-left: 5px;
-}
-
-.navbar section > :not(*:last-child) {
- padding-right: 5px;
-}
-
-.navbar a {
- text-decoration: none;
- color: #343a40;
-}
-
-.navbar a:hover {
- color: black;
-}
-
-.navbar-contents {
- width: 100%;
- display: flex;
- box-sizing: border-box;
-}
-
-.navbar-contents > * {
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-/* Forms */
-
-form {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: fit-content;
-}
-
-.main > div > form {
- margin-top: 10px;
-}
-
-.main > div > form:first-child {
- width: 100%;
- max-width: 300px;
- margin-left: auto;
- margin-right: auto;
-}
-
-form > * {
- width: 100%;
- box-sizing: border-box;
-}
-
-input {
- margin: 5px;
- padding: 9px;
- border: 1px solid darkgrey;
- border-radius: 4px;
-}
-
-input[type="submit"] {
- color: white;
- background-color: black;
-}
-
-input[type="submit"]:hover {
- cursor: pointer;
-}
-
-.form-error {
- font-size: 0.8em;
- color: red;
-}
-
-/* Other general stuff */
-
-.flex-spacer {
- flex: 1;
-}
diff --git a/ExamTemplate/Web/wwwroot/favicon.ico b/ExamTemplate/Web/wwwroot/favicon.ico
deleted file mode 100644
index a3a7999..0000000
Binary files a/ExamTemplate/Web/wwwroot/favicon.ico and /dev/null differ
--
cgit v1.2.3