diff --git a/.idea/.idea.TRPZ_PrintService/.idea/workspace.xml b/.idea/.idea.TRPZ_PrintService/.idea/workspace.xml index 83ee997..d75215f 100644 --- a/.idea/.idea.TRPZ_PrintService/.idea/workspace.xml +++ b/.idea/.idea.TRPZ_PrintService/.idea/workspace.xml @@ -1,68 +1,66 @@ - - TRPZ_PrintService/TRPZ_PrintService.csproj WebApplication1/WebApplication1.csproj - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -263,7 +275,8 @@ - diff --git a/TRPZ_PrintService/Areas/Identity/IdentityHostingStartup.cs b/TRPZ_PrintService/Areas/Identity/IdentityHostingStartup.cs index 00cb52c..4123925 100644 --- a/TRPZ_PrintService/Areas/Identity/IdentityHostingStartup.cs +++ b/TRPZ_PrintService/Areas/Identity/IdentityHostingStartup.cs @@ -1,14 +1,12 @@ -using System; -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.UI; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using TRPZ_PrintService.Areas.Identity; using TRPZ_PrintService.Areas.Identity.Data; using TRPZ_PrintService.Data; -[assembly: HostingStartup(typeof(TRPZ_PrintService.Areas.Identity.IdentityHostingStartup))] +[assembly: HostingStartup(typeof(IdentityHostingStartup))] namespace TRPZ_PrintService.Areas.Identity { diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs index e75502d..992b4c4 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace TRPZ_PrintService.Areas.Identity.Pages.Account { diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs index 1c79ef0..caae318 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs index 6bc3ab7..58f06fd 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; @@ -15,8 +12,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class ConfirmEmailChangeModel : PageModel { - private readonly UserManager _userManager; private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public ConfirmEmailChangeModel(UserManager userManager, SignInManager signInManager) diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs index 2fd41ee..f9be84d 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; @@ -20,10 +17,10 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class ExternalLoginModel : PageModel { - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; private readonly IEmailSender _emailSender; private readonly ILogger _logger; + private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public ExternalLoginModel( SignInManager signInManager, @@ -45,11 +42,6 @@ public ExternalLoginModel( [TempData] public string ErrorMessage { get; set; } - public class InputModel - { - [Required] [EmailAddress] public string Email { get; set; } - } - public IActionResult OnGetAsync() { return RedirectToPage("./Login"); @@ -93,18 +85,16 @@ public async Task OnGetCallbackAsync(string returnUrl = null, str { return RedirectToPage("./Lockout"); } - else - { - // If the user does not have an account, then ask the user to create an account. - ReturnUrl = returnUrl; - ProviderDisplayName = info.ProviderDisplayName; - if (info.Principal.HasClaim(c => c.Type == ClaimTypes.Email)) - Input = new InputModel - { - Email = info.Principal.FindFirstValue(ClaimTypes.Email) - }; - return Page(); - } + + // If the user does not have an account, then ask the user to create an account. + ReturnUrl = returnUrl; + ProviderDisplayName = info.ProviderDisplayName; + if (info.Principal.HasClaim(c => c.Type == ClaimTypes.Email)) + Input = new InputModel + { + Email = info.Principal.FindFirstValue(ClaimTypes.Email) + }; + return Page(); } public async Task OnPostConfirmationAsync(string returnUrl = null) @@ -136,7 +126,7 @@ public async Task OnPostConfirmationAsync(string returnUrl = null var callbackUrl = Url.Page( "/Account/ConfirmEmail", null, - new {area = "Identity", userId = userId, code = code}, + new {area = "Identity", userId, code}, Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", @@ -144,7 +134,7 @@ await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", // If account confirmation is required, we need to show the link if we don't have a real email sender if (_userManager.Options.SignIn.RequireConfirmedAccount) - return RedirectToPage("./RegisterConfirmation", new {Email = Input.Email}); + return RedirectToPage("./RegisterConfirmation", new {Input.Email}); await _signInManager.SignInAsync(user, false, info.LoginProvider); @@ -159,5 +149,10 @@ await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", ReturnUrl = returnUrl; return Page(); } + + public class InputModel + { + [Required] [EmailAddress] public string Email { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs index b69c66a..8419ef3 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text.Encodings.Web; +using System.ComponentModel.DataAnnotations; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; @@ -17,8 +15,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class ForgotPasswordModel : PageModel { - private readonly UserManager _userManager; private readonly IEmailSender _emailSender; + private readonly UserManager _userManager; public ForgotPasswordModel(UserManager userManager, IEmailSender emailSender) { @@ -28,11 +26,6 @@ public ForgotPasswordModel(UserManager userManager, IEmai [BindProperty] public InputModel Input { get; set; } - public class InputModel - { - [Required] [EmailAddress] public string Email { get; set; } - } - public async Task OnPostAsync() { if (ModelState.IsValid) @@ -62,5 +55,10 @@ await _emailSender.SendEmailAsync( return Page(); } + + public class InputModel + { + [Required] [EmailAddress] public string Email { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs index 63ed5f1..cc2a59c 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; namespace TRPZ_PrintService.Areas.Identity.Pages.Account diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Lockout.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Lockout.cshtml.cs index 9f58448..08d0d4e 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Lockout.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Lockout.cshtml.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; namespace TRPZ_PrintService.Areas.Identity.Pages.Account diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Login.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Login.cshtml.cs index f11452a..9e06964 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Login.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Login.cshtml.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; -using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; @@ -18,9 +15,9 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class LoginModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; private readonly ILogger _logger; + private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public LoginModel(SignInManager signInManager, ILogger logger, @@ -39,17 +36,6 @@ public LoginModel(SignInManager signInManager, [TempData] public string ErrorMessage { get; set; } - public class InputModel - { - [Required] [EmailAddress] public string Email { get; set; } - - [Required] - [DataType(DataType.Password)] - public string Password { get; set; } - - [Display(Name = "Remember me?")] public bool RememberMe { get; set; } - } - public async Task OnGetAsync(string returnUrl = null) { if (!string.IsNullOrEmpty(ErrorMessage)) ModelState.AddModelError(string.Empty, ErrorMessage); @@ -83,21 +69,30 @@ public async Task OnPostAsync(string returnUrl = null) } if (result.RequiresTwoFactor) - return RedirectToPage("./LoginWith2fa", new {ReturnUrl = returnUrl, RememberMe = Input.RememberMe}); + return RedirectToPage("./LoginWith2fa", new {ReturnUrl = returnUrl, Input.RememberMe}); if (result.IsLockedOut) { _logger.LogWarning("User account locked out."); return RedirectToPage("./Lockout"); } - else - { - ModelState.AddModelError(string.Empty, "Invalid login attempt."); - return Page(); - } + + ModelState.AddModelError(string.Empty, "Invalid login attempt."); + return Page(); } // If we got this far, something failed, redisplay form return Page(); } + + public class InputModel + { + [Required] [EmailAddress] public string Email { get; set; } + + [Required] + [DataType(DataType.Password)] + public string Password { get; set; } + + [Display(Name = "Remember me?")] public bool RememberMe { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs index 7e86913..2aef52b 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; @@ -15,8 +13,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class LoginWith2faModel : PageModel { - private readonly SignInManager _signInManager; private readonly ILogger _logger; + private readonly SignInManager _signInManager; public LoginWith2faModel(SignInManager signInManager, ILogger logger) { @@ -30,25 +28,12 @@ public LoginWith2faModel(SignInManager signInManager, ILo public string ReturnUrl { get; set; } - public class InputModel - { - [Required] - [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", - MinimumLength = 6)] - [DataType(DataType.Text)] - [Display(Name = "Authenticator code")] - public string TwoFactorCode { get; set; } - - [Display(Name = "Remember this machine")] - public bool RememberMachine { get; set; } - } - public async Task OnGetAsync(bool rememberMe, string returnUrl = null) { // Ensure the user has gone through the username & password screen first var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) throw new InvalidOperationException($"Unable to load two-factor authentication user."); + if (user == null) throw new InvalidOperationException("Unable to load two-factor authentication user."); ReturnUrl = returnUrl; RememberMe = rememberMe; @@ -63,7 +48,7 @@ public async Task OnPostAsync(bool rememberMe, string returnUrl = returnUrl = returnUrl ?? Url.Content("~/"); var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) throw new InvalidOperationException($"Unable to load two-factor authentication user."); + if (user == null) throw new InvalidOperationException("Unable to load two-factor authentication user."); var authenticatorCode = Input.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty); @@ -76,17 +61,29 @@ await _signInManager.TwoFactorAuthenticatorSignInAsync(authenticatorCode, rememb _logger.LogInformation("User with ID '{UserId}' logged in with 2fa.", user.Id); return LocalRedirect(returnUrl); } - else if (result.IsLockedOut) + + if (result.IsLockedOut) { _logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id); return RedirectToPage("./Lockout"); } - else - { - _logger.LogWarning("Invalid authenticator code entered for user with ID '{UserId}'.", user.Id); - ModelState.AddModelError(string.Empty, "Invalid authenticator code."); - return Page(); - } + + _logger.LogWarning("Invalid authenticator code entered for user with ID '{UserId}'.", user.Id); + ModelState.AddModelError(string.Empty, "Invalid authenticator code."); + return Page(); + } + + public class InputModel + { + [Required] + [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", + MinimumLength = 6)] + [DataType(DataType.Text)] + [Display(Name = "Authenticator code")] + public string TwoFactorCode { get; set; } + + [Display(Name = "Remember this machine")] + public bool RememberMachine { get; set; } } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs index ea65c3a..0715e3c 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; @@ -15,8 +13,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class LoginWithRecoveryCodeModel : PageModel { - private readonly SignInManager _signInManager; private readonly ILogger _logger; + private readonly SignInManager _signInManager; public LoginWithRecoveryCodeModel(SignInManager signInManager, ILogger logger) @@ -29,20 +27,11 @@ public LoginWithRecoveryCodeModel(SignInManager signInMan public string ReturnUrl { get; set; } - public class InputModel - { - [BindProperty] - [Required] - [DataType(DataType.Text)] - [Display(Name = "Recovery Code")] - public string RecoveryCode { get; set; } - } - public async Task OnGetAsync(string returnUrl = null) { // Ensure the user has gone through the username & password screen first var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) throw new InvalidOperationException($"Unable to load two-factor authentication user."); + if (user == null) throw new InvalidOperationException("Unable to load two-factor authentication user."); ReturnUrl = returnUrl; @@ -54,7 +43,7 @@ public async Task OnPostAsync(string returnUrl = null) if (!ModelState.IsValid) return Page(); var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) throw new InvalidOperationException($"Unable to load two-factor authentication user."); + if (user == null) throw new InvalidOperationException("Unable to load two-factor authentication user."); var recoveryCode = Input.RecoveryCode.Replace(" ", string.Empty); @@ -71,12 +60,19 @@ public async Task OnPostAsync(string returnUrl = null) _logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id); return RedirectToPage("./Lockout"); } - else - { - _logger.LogWarning("Invalid recovery code entered for user with ID '{UserId}' ", user.Id); - ModelState.AddModelError(string.Empty, "Invalid recovery code entered."); - return Page(); - } + + _logger.LogWarning("Invalid recovery code entered for user with ID '{UserId}' ", user.Id); + ModelState.AddModelError(string.Empty, "Invalid recovery code entered."); + return Page(); + } + + public class InputModel + { + [BindProperty] + [Required] + [DataType(DataType.Text)] + [Display(Name = "Recovery Code")] + public string RecoveryCode { get; set; } } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Logout.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Logout.cshtml.cs index aff1167..52bb8da 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Logout.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Logout.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -14,8 +11,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class LogoutModel : PageModel { - private readonly SignInManager _signInManager; private readonly ILogger _logger; + private readonly SignInManager _signInManager; public LogoutModel(SignInManager signInManager, ILogger logger) { @@ -33,8 +30,7 @@ public async Task OnPost(string returnUrl = null) _logger.LogInformation("User logged out."); if (returnUrl != null) return LocalRedirect(returnUrl); - else - return RedirectToPage(); + return RedirectToPage(); } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs index 5ba0a0e..7525260 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -13,9 +10,9 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class ChangePasswordModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; private readonly ILogger _logger; + private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public ChangePasswordModel( UserManager userManager, @@ -31,26 +28,6 @@ public ChangePasswordModel( [TempData] public string StatusMessage { get; set; } - public class InputModel - { - [Required] - [DataType(DataType.Password)] - [Display(Name = "Current password")] - public string OldPassword { get; set; } - - [Required] - [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", - MinimumLength = 6)] - [DataType(DataType.Password)] - [Display(Name = "New password")] - public string NewPassword { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm new password")] - [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } - public async Task OnGetAsync() { var user = await _userManager.GetUserAsync(User); @@ -84,5 +61,25 @@ public async Task OnPostAsync() return RedirectToPage(); } + + public class InputModel + { + [Required] + [DataType(DataType.Password)] + [Display(Name = "Current password")] + public string OldPassword { get; set; } + + [Required] + [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", + MinimumLength = 6)] + [DataType(DataType.Password)] + [Display(Name = "New password")] + public string NewPassword { get; set; } + + [DataType(DataType.Password)] + [Display(Name = "Confirm new password")] + [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] + public string ConfirmPassword { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs index c491f16..22a7393 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs @@ -11,9 +11,9 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class DeletePersonalDataModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; private readonly ILogger _logger; + private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public DeletePersonalDataModel( UserManager userManager, @@ -27,13 +27,6 @@ public DeletePersonalDataModel( [BindProperty] public InputModel Input { get; set; } - public class InputModel - { - [Required] - [DataType(DataType.Password)] - public string Password { get; set; } - } - public bool RequirePassword { get; set; } public async Task OnGet() @@ -69,5 +62,12 @@ public async Task OnPostAsync() return Redirect("~/"); } + + public class InputModel + { + [Required] + [DataType(DataType.Password)] + public string Password { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs index c5325f9..cf1737e 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -12,8 +10,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class Disable2faModel : PageModel { - private readonly UserManager _userManager; private readonly ILogger _logger; + private readonly UserManager _userManager; public Disable2faModel( UserManager userManager, diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs index 5b0748e..a5dfe71 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Text.Json; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; @@ -14,8 +13,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class DownloadPersonalDataModel : PageModel { - private readonly UserManager _userManager; private readonly ILogger _logger; + private readonly UserManager _userManager; public DownloadPersonalDataModel( UserManager userManager, diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs index d430b0e..5387564 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.Text; using System.Text.Encodings.Web; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI.Services; @@ -14,11 +11,11 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { - public partial class EmailModel : PageModel + public class EmailModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; private readonly IEmailSender _emailSender; + private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public EmailModel( UserManager userManager, @@ -40,14 +37,6 @@ public EmailModel( [BindProperty] public InputModel Input { get; set; } - public class InputModel - { - [Required] - [EmailAddress] - [Display(Name = "New email")] - public string NewEmail { get; set; } - } - private async Task LoadAsync(TRPZ_PrintServiceUser user) { var email = await _userManager.GetEmailAsync(user); @@ -90,7 +79,7 @@ public async Task OnPostChangeEmailAsync() var callbackUrl = Url.Page( "/Account/ConfirmEmailChange", null, - new {userId = userId, email = Input.NewEmail, code = code}, + new {userId, email = Input.NewEmail, code}, Request.Scheme); await _emailSender.SendEmailAsync( Input.NewEmail, @@ -123,7 +112,7 @@ public async Task OnPostSendVerificationEmailAsync() var callbackUrl = Url.Page( "/Account/ConfirmEmail", null, - new {area = "Identity", userId = userId, code = code}, + new {area = "Identity", userId, code}, Request.Scheme); await _emailSender.SendEmailAsync( email, @@ -133,5 +122,13 @@ await _emailSender.SendEmailAsync( StatusMessage = "Verification email sent. Please check your email."; return RedirectToPage(); } + + public class InputModel + { + [Required] + [EmailAddress] + [Display(Name = "New email")] + public string NewEmail { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml index 8e13d2e..20e8a07 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml @@ -24,7 +24,7 @@

Scan the QR Code or enter this key @Model.SharedKey into your two factor authenticator app. Spaces and casing do not matter.

-
+
  • diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs index 7040657..0021bd0 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs @@ -1,10 +1,7 @@ -using System; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Text; using System.Text.Encodings.Web; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -16,11 +13,10 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class EnableAuthenticatorModel : PageModel { - private readonly UserManager _userManager; + private const string AuthenticatorUriFormat = "otpauth://totp/{0}:{1}?secret={2}&issuer={0}&digits=6"; private readonly ILogger _logger; private readonly UrlEncoder _urlEncoder; - - private const string AuthenticatorUriFormat = "otpauth://totp/{0}:{1}?secret={2}&issuer={0}&digits=6"; + private readonly UserManager _userManager; public EnableAuthenticatorModel( UserManager userManager, @@ -42,16 +38,6 @@ public EnableAuthenticatorModel( [BindProperty] public InputModel Input { get; set; } - public class InputModel - { - [Required] - [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", - MinimumLength = 6)] - [DataType(DataType.Text)] - [Display(Name = "Verification Code")] - public string Code { get; set; } - } - public async Task OnGetAsync() { var user = await _userManager.GetUserAsync(User); @@ -98,10 +84,8 @@ public async Task OnPostAsync() RecoveryCodes = recoveryCodes.ToArray(); return RedirectToPage("./ShowRecoveryCodes"); } - else - { - return RedirectToPage("./TwoFactorAuthentication"); - } + + return RedirectToPage("./TwoFactorAuthentication"); } private async Task LoadSharedKeyAndQrCodeUriAsync(TRPZ_PrintServiceUser user) @@ -143,5 +127,15 @@ private string GenerateQrCodeUri(string email, string unformattedKey) _urlEncoder.Encode(email), unformattedKey); } + + public class InputModel + { + [Required] + [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", + MinimumLength = 6)] + [DataType(DataType.Text)] + [Display(Name = "Verification Code")] + public string Code { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs index eba79de..b140ec0 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs @@ -12,8 +12,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class ExternalLoginsModel : PageModel { - private readonly UserManager _userManager; private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public ExternalLoginsModel( UserManager userManager, @@ -34,7 +34,7 @@ public ExternalLoginsModel( public async Task OnGetAsync() { var user = await _userManager.GetUserAsync(User); - if (user == null) return NotFound($"Unable to load user with ID 'user.Id'."); + if (user == null) return NotFound("Unable to load user with ID 'user.Id'."); CurrentLogins = await _userManager.GetLoginsAsync(user); OtherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()) @@ -47,7 +47,7 @@ public async Task OnGetAsync() public async Task OnPostRemoveLoginAsync(string loginProvider, string providerKey) { var user = await _userManager.GetUserAsync(User); - if (user == null) return NotFound($"Unable to load user with ID 'user.Id'."); + if (user == null) return NotFound("Unable to load user with ID 'user.Id'."); var result = await _userManager.RemoveLoginAsync(user, loginProvider, providerKey); if (!result.Succeeded) @@ -77,7 +77,7 @@ public async Task OnPostLinkLoginAsync(string provider) public async Task OnGetLinkLoginCallbackAsync() { var user = await _userManager.GetUserAsync(User); - if (user == null) return NotFound($"Unable to load user with ID 'user.Id'."); + if (user == null) return NotFound("Unable to load user with ID 'user.Id'."); var info = await _signInManager.GetExternalLoginInfoAsync(user.Id); if (info == null) diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs index 3be51a7..6c8d04a 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; @@ -12,8 +11,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class GenerateRecoveryCodesModel : PageModel { - private readonly UserManager _userManager; private readonly ILogger _logger; + private readonly UserManager _userManager; public GenerateRecoveryCodesModel( UserManager userManager, diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs index 899e189..90ac7d2 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -10,10 +7,10 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { - public partial class IndexModel : PageModel + public class IndexModel : PageModel { - private readonly UserManager _userManager; private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public IndexModel( UserManager userManager, @@ -29,13 +26,6 @@ public IndexModel( [BindProperty] public InputModel Input { get; set; } - public class InputModel - { - [Phone] - [Display(Name = "Phone number")] - public string PhoneNumber { get; set; } - } - private async Task LoadAsync(TRPZ_PrintServiceUser user) { var userName = await _userManager.GetUserNameAsync(user); @@ -84,5 +74,12 @@ public async Task OnPostAsync() StatusMessage = "Your profile has been updated"; return RedirectToPage(); } + + public class InputModel + { + [Phone] + [Display(Name = "Phone number")] + public string PhoneNumber { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs index 77abf91..2eba6ba 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.IO; using Microsoft.AspNetCore.Mvc.Rendering; namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage @@ -67,7 +65,7 @@ public static string TwoFactorAuthenticationNavClass(ViewContext viewContext) private static string PageNavClass(ViewContext viewContext, string page) { var activePage = viewContext.ViewData["ActivePage"] as string - ?? System.IO.Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName); + ?? Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName); return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null; } } diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs index 297a384..57375a4 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs @@ -9,8 +9,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class PersonalDataModel : PageModel { - private readonly UserManager _userManager; private readonly ILogger _logger; + private readonly UserManager _userManager; public PersonalDataModel( UserManager userManager, diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs index c3a0680..54c8586 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -12,9 +9,9 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class ResetAuthenticatorModel : PageModel { - private UserManager _userManager; private readonly SignInManager _signInManager; - private ILogger _logger; + private readonly ILogger _logger; + private readonly UserManager _userManager; public ResetAuthenticatorModel( UserManager userManager, diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs index 720ebe2..a5a117b 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -12,8 +9,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { public class SetPasswordModel : PageModel { - private readonly UserManager _userManager; private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public SetPasswordModel( UserManager userManager, @@ -27,21 +24,6 @@ public SetPasswordModel( [TempData] public string StatusMessage { get; set; } - public class InputModel - { - [Required] - [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", - MinimumLength = 6)] - [DataType(DataType.Password)] - [Display(Name = "New password")] - public string NewPassword { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm new password")] - [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } - public async Task OnGetAsync() { var user = await _userManager.GetUserAsync(User); @@ -74,5 +56,20 @@ public async Task OnPostAsync() return RedirectToPage(); } + + public class InputModel + { + [Required] + [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", + MinimumLength = 6)] + [DataType(DataType.Password)] + [Display(Name = "New password")] + public string NewPassword { get; set; } + + [DataType(DataType.Password)] + [Display(Name = "Confirm new password")] + [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] + public string ConfirmPassword { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs index 697b692..e7214f1 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs @@ -1,12 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using TRPZ_PrintService.Areas.Identity.Data; namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage { diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs index 02b1885..16045ba 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -13,10 +10,10 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account.Manage public class TwoFactorAuthenticationModel : PageModel { private const string AuthenicatorUriFormat = "otpauth://totp/{0}:{1}?secret={2}&issuer={0}"; + private readonly ILogger _logger; + private readonly SignInManager _signInManager; private readonly UserManager _userManager; - private readonly SignInManager _signInManager; - private readonly ILogger _logger; public TwoFactorAuthenticationModel( UserManager userManager, diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/Register.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/Register.cshtml.cs index af1302c..e40fa5b 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; @@ -20,11 +19,11 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class RegisterModel : PageModel { - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; - private readonly ILogger _logger; private readonly IEmailSender _emailSender; + private readonly ILogger _logger; private readonly RoleManager _roleManager; + private readonly SignInManager _signInManager; + private readonly UserManager _userManager; public RegisterModel( UserManager userManager, @@ -46,36 +45,6 @@ public RegisterModel( public IList ExternalLogins { get; set; } - public class InputModel - { - [Required] - [DataType(DataType.Text)] - [Display(Name = "First name")] - public string FirstName { get; set; } - - [Required] - [DataType(DataType.Text)] - [Display(Name = "Last name")] - public string LastName { get; set; } - - [Required] - [EmailAddress] - [Display(Name = "Email")] - public string Email { get; set; } - - [Required] - [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", - MinimumLength = 6)] - [DataType(DataType.Password)] - [Display(Name = "Password")] - public string Password { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm password")] - [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } - public async Task OnGetAsync(string returnUrl = null) { ReturnUrl = returnUrl; @@ -118,7 +87,7 @@ public async Task OnPostAsync(string returnUrl = null) var callbackUrl = Url.Page( "/Account/ConfirmEmail", null, - new {area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl}, + new {area = "Identity", userId = user.Id, code, returnUrl}, Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", @@ -126,13 +95,11 @@ await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", if (_userManager.Options.SignIn.RequireConfirmedAccount) { - return RedirectToPage("RegisterConfirmation", new {email = Input.Email, returnUrl = returnUrl}); - } - else - { - await _signInManager.SignInAsync(user, false); - return LocalRedirect(returnUrl); + return RedirectToPage("RegisterConfirmation", new {email = Input.Email, returnUrl}); } + + await _signInManager.SignInAsync(user, false); + return LocalRedirect(returnUrl); } foreach (var error in result.Errors) ModelState.AddModelError(string.Empty, error.Description); @@ -141,5 +108,35 @@ await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", // If we got this far, something failed, redisplay form return Page(); } + + public class InputModel + { + [Required] + [DataType(DataType.Text)] + [Display(Name = "First name")] + public string FirstName { get; set; } + + [Required] + [DataType(DataType.Text)] + [Display(Name = "Last name")] + public string LastName { get; set; } + + [Required] + [EmailAddress] + [Display(Name = "Email")] + public string Email { get; set; } + + [Required] + [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", + MinimumLength = 6)] + [DataType(DataType.Password)] + [Display(Name = "Password")] + public string Password { get; set; } + + [DataType(DataType.Password)] + [Display(Name = "Confirm password")] + [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] + public string ConfirmPassword { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml b/TRPZ_PrintService/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml index ea08e7e..adc1064 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml @@ -6,7 +6,7 @@

    @ViewData["Title"]

    @{ - if (@Model.DisplayConfirmAccountLink) + if (Model.DisplayConfirmAccountLink) {

    This app does not currently have a real email sender registered, see these docs for how to configure a real email sender. diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs index d0eb8f6..f95b30e 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs @@ -1,6 +1,6 @@ -using Microsoft.AspNetCore.Authorization; -using System.Text; +using System.Text; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Mvc; @@ -13,8 +13,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class RegisterConfirmationModel : PageModel { - private readonly UserManager _userManager; private readonly IEmailSender _sender; + private readonly UserManager _userManager; public RegisterConfirmationModel(UserManager userManager, IEmailSender sender) { @@ -46,7 +46,7 @@ public async Task OnGetAsync(string email, string returnUrl = nul EmailConfirmationUrl = Url.Page( "/Account/ConfirmEmail", null, - new {area = "Identity", userId = userId, code = code, returnUrl = returnUrl}, + new {area = "Identity", userId, code, returnUrl}, Request.Scheme); } diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs index fcf2a16..337c6c3 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; @@ -16,8 +15,8 @@ namespace TRPZ_PrintService.Areas.Identity.Pages.Account [AllowAnonymous] public class ResendEmailConfirmationModel : PageModel { - private readonly UserManager _userManager; private readonly IEmailSender _emailSender; + private readonly UserManager _userManager; public ResendEmailConfirmationModel(UserManager userManager, IEmailSender emailSender) { @@ -27,11 +26,6 @@ public ResendEmailConfirmationModel(UserManager userManag [BindProperty] public InputModel Input { get; set; } - public class InputModel - { - [Required] [EmailAddress] public string Email { get; set; } - } - public void OnGet() { } @@ -53,7 +47,7 @@ public async Task OnPostAsync() var callbackUrl = Url.Page( "/Account/ConfirmEmail", null, - new {userId = userId, code = code}, + new {userId, code}, Request.Scheme); await _emailSender.SendEmailAsync( Input.Email, @@ -63,5 +57,10 @@ await _emailSender.SendEmailAsync( ModelState.AddModelError(string.Empty, "Verification email sent. Please check your email."); return Page(); } + + public class InputModel + { + [Required] [EmailAddress] public string Email { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs index 9b3a25b..819d4d3 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; @@ -25,38 +22,18 @@ public ResetPasswordModel(UserManager userManager) [BindProperty] public InputModel Input { get; set; } - public class InputModel - { - [Required] [EmailAddress] public string Email { get; set; } - - [Required] - [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", - MinimumLength = 6)] - [DataType(DataType.Password)] - public string Password { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm password")] - [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - - public string Code { get; set; } - } - public IActionResult OnGet(string code = null) { if (code == null) { return BadRequest("A code must be supplied for password reset."); } - else + + Input = new InputModel { - Input = new InputModel - { - Code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)) - }; - return Page(); - } + Code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)) + }; + return Page(); } public async Task OnPostAsync() @@ -74,5 +51,23 @@ public async Task OnPostAsync() foreach (var error in result.Errors) ModelState.AddModelError(string.Empty, error.Description); return Page(); } + + public class InputModel + { + [Required] [EmailAddress] public string Email { get; set; } + + [Required] + [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", + MinimumLength = 6)] + [DataType(DataType.Password)] + public string Password { get; set; } + + [DataType(DataType.Password)] + [Display(Name = "Confirm password")] + [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] + public string ConfirmPassword { get; set; } + + public string Code { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml.cs b/TRPZ_PrintService/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml.cs index fddc9f8..e9bf40f 100644 --- a/TRPZ_PrintService/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml.cs +++ b/TRPZ_PrintService/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; namespace TRPZ_PrintService.Areas.Identity.Pages.Account diff --git a/TRPZ_PrintService/Data/Material.cs b/TRPZ_PrintService/Data/Material.cs index d736172..0ba9a1f 100644 --- a/TRPZ_PrintService/Data/Material.cs +++ b/TRPZ_PrintService/Data/Material.cs @@ -1,7 +1,5 @@ -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Data.SqlTypes; namespace TRPZ_PrintService.Data { diff --git a/TRPZ_PrintService/Data/Model3D.cs b/TRPZ_PrintService/Data/Model3D.cs index 1020123..fb7896a 100644 --- a/TRPZ_PrintService/Data/Model3D.cs +++ b/TRPZ_PrintService/Data/Model3D.cs @@ -1,5 +1,3 @@ -using System; - namespace TRPZ_PrintService.Data { public class Model3D diff --git a/TRPZ_PrintService/Data/ModelInOrder.cs b/TRPZ_PrintService/Data/ModelInOrder.cs index 16f26b5..69ac517 100644 --- a/TRPZ_PrintService/Data/ModelInOrder.cs +++ b/TRPZ_PrintService/Data/ModelInOrder.cs @@ -1,11 +1,14 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; using TRPZ_PrintService.Areas.Identity.Data; namespace TRPZ_PrintService.Data { public class ModelInOrder { + public ModelInOrder() + { + Scale = 1; + } + public int ModelInOrderId { get; set; } public double Scale { get; set; } public bool HasSolubleSupports { get; set; } //restricts usage only on multi-material printers @@ -19,11 +22,6 @@ public class ModelInOrder public Printer Printer { get; set; } public Model3D Model { get; set; } - public ModelInOrder() - { - Scale = 1; - } - public override string ToString() { return Model.Description; diff --git a/TRPZ_PrintService/Data/Order.cs b/TRPZ_PrintService/Data/Order.cs index 8a2744e..33335f3 100644 --- a/TRPZ_PrintService/Data/Order.cs +++ b/TRPZ_PrintService/Data/Order.cs @@ -8,6 +8,20 @@ namespace TRPZ_PrintService.Data { public class Order { + public enum OrderStatus + { + NotSent, + Sent, + Confirmed, + Finished, + Cancelled + } + + public Order() + { + Models = new List(); + } + public int OrderId { get; set; } public DateTime Timestamp { get; set; } public TimeSpan TotalPrintTime { get; set; } @@ -23,20 +37,5 @@ public int PriceTotal { get { return Models.Sum(x => x.PriceTotal) + Models.Sum(x => x.PostProcessing.Price); } } - - - public enum OrderStatus - { - NotSent, - Sent, - Confirmed, - Finished, - Cancelled - } - - public Order() - { - Models = new List(); - } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Data/PostProcessing.cs b/TRPZ_PrintService/Data/PostProcessing.cs index 98c6c87..fc4f0ae 100644 --- a/TRPZ_PrintService/Data/PostProcessing.cs +++ b/TRPZ_PrintService/Data/PostProcessing.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace TRPZ_PrintService.Data diff --git a/TRPZ_PrintService/Data/Printer.cs b/TRPZ_PrintService/Data/Printer.cs index 83ce25b..b6b30d5 100644 --- a/TRPZ_PrintService/Data/Printer.cs +++ b/TRPZ_PrintService/Data/Printer.cs @@ -1,6 +1,3 @@ -using System; -using System.Drawing; - namespace TRPZ_PrintService.Data { public class Printer diff --git a/TRPZ_PrintService/Data/TRPZ_PrintServiceContext.cs b/TRPZ_PrintService/Data/TRPZ_PrintServiceContext.cs index 3051613..a0b3300 100644 --- a/TRPZ_PrintService/Data/TRPZ_PrintServiceContext.cs +++ b/TRPZ_PrintService/Data/TRPZ_PrintServiceContext.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using TRPZ_PrintService.Data; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using TRPZ_PrintService.Areas.Identity.Data; @@ -12,6 +6,11 @@ namespace TRPZ_PrintService.Data { public class TRPZ_PrintServiceContext : IdentityDbContext { + public TRPZ_PrintServiceContext(DbContextOptions options) + : base(options) + { + } + // public DbSet Clients { get; set; } // public DbSet Managers { get; set; } public DbSet Materials { get; set; } @@ -23,11 +22,6 @@ public class TRPZ_PrintServiceContext : IdentityDbContext public DbSet Printers { get; set; } public DbSet PromoCodes { get; set; } - public TRPZ_PrintServiceContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); diff --git a/TRPZ_PrintService/Data/TRPZ_PrintServiceUser.cs b/TRPZ_PrintService/Data/TRPZ_PrintServiceUser.cs index 832ade2..e1d9209 100644 --- a/TRPZ_PrintService/Data/TRPZ_PrintServiceUser.cs +++ b/TRPZ_PrintService/Data/TRPZ_PrintServiceUser.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; using Microsoft.AspNetCore.Identity; using TRPZ_PrintService.Data; diff --git a/TRPZ_PrintService/Migrations/TRPZ_PrintServiceContextModelSnapshot.cs b/TRPZ_PrintService/Migrations/TRPZ_PrintServiceContextModelSnapshot.cs index cb68798..b01c7cd 100644 --- a/TRPZ_PrintService/Migrations/TRPZ_PrintServiceContextModelSnapshot.cs +++ b/TRPZ_PrintService/Migrations/TRPZ_PrintServiceContextModelSnapshot.cs @@ -3,14 +3,12 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using TRPZ_PrintService.Data; namespace TRPZ_PrintService.Migrations { [DbContext(typeof(TRPZ_PrintServiceContext))] - internal partial class TRPZ_PrintServiceContextModelSnapshot : ModelSnapshot + internal class TRPZ_PrintServiceContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { diff --git a/TRPZ_PrintService/Pages/EditMIO.cshtml.cs b/TRPZ_PrintService/Pages/EditMIO.cshtml.cs index a1cf3c4..6667795 100644 --- a/TRPZ_PrintService/Pages/EditMIO.cshtml.cs +++ b/TRPZ_PrintService/Pages/EditMIO.cshtml.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -10,7 +9,12 @@ namespace TRPZ_PrintService.Pages { public class EditMIO : PageModel { - private TRPZ_PrintServiceContext _context; + private readonly TRPZ_PrintServiceContext _context; + + public EditMIO(TRPZ_PrintServiceContext context) + { + _context = context; + } public SelectList Materials { get; set; } @@ -20,30 +24,8 @@ public class EditMIO : PageModel [BindProperty] public Order order { get; set; } public ModelInOrder mio { get; set; } - - public class FormModel - { - public double Scale { get; set; } - public bool HasSolubleSupports { get; set; } - public int PostProcessingId { get; set; } - public string Description { get; set; } - - public int InfillPercentage { get; set; } - public int Layerheight { get; set; } - public int NozzleDiameter { get; set; } - - public int PrinterId { get; set; } - public int MaterialId { get; set; } - public int Price { get; set; } - } - [BindProperty] public FormModel Fmodel { get; set; } - public EditMIO(TRPZ_PrintServiceContext context) - { - _context = context; - } - public IActionResult OnGetEdit(int? orderId, int mioid) { @@ -114,5 +96,22 @@ public IActionResult OnPostEdit(int? orderId, int mioid) return new RedirectToPageResult("/ModelInOrder", "", new {id = order.OrderId}); } + + + public class FormModel + { + public double Scale { get; set; } + public bool HasSolubleSupports { get; set; } + public int PostProcessingId { get; set; } + public string Description { get; set; } + + public int InfillPercentage { get; set; } + public int Layerheight { get; set; } + public int NozzleDiameter { get; set; } + + public int PrinterId { get; set; } + public int MaterialId { get; set; } + public int Price { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Pages/Error.cshtml.cs b/TRPZ_PrintService/Pages/Error.cshtml.cs index 32c77ba..9cb966f 100644 --- a/TRPZ_PrintService/Pages/Error.cshtml.cs +++ b/TRPZ_PrintService/Pages/Error.cshtml.cs @@ -1,11 +1,7 @@ +using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; namespace TRPZ_PrintService.Pages { @@ -13,10 +9,6 @@ namespace TRPZ_PrintService.Pages [IgnoreAntiforgeryToken] public class ErrorModel : PageModel { - public string RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - private readonly ILogger _logger; public ErrorModel(ILogger logger) @@ -24,6 +16,10 @@ public ErrorModel(ILogger logger) _logger = logger; } + public string RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + public void OnGet() { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; diff --git a/TRPZ_PrintService/Pages/Index.cshtml.cs b/TRPZ_PrintService/Pages/Index.cshtml.cs index c7151e0..df1ba9e 100644 --- a/TRPZ_PrintService/Pages/Index.cshtml.cs +++ b/TRPZ_PrintService/Pages/Index.cshtml.cs @@ -1,11 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; namespace TRPZ_PrintService.Pages { diff --git a/TRPZ_PrintService/Pages/ManageOrders.cshtml.cs b/TRPZ_PrintService/Pages/ManageOrders.cshtml.cs index 767009f..81f5408 100644 --- a/TRPZ_PrintService/Pages/ManageOrders.cshtml.cs +++ b/TRPZ_PrintService/Pages/ManageOrders.cshtml.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -13,17 +12,17 @@ namespace TRPZ_PrintService.Pages { public class ManageOrders : PageModel { - private TRPZ_PrintServiceContext _context; + private readonly TRPZ_PrintServiceContext _context; private UserManager _userManager; - public IList Orders { get; set; } - public ManageOrders(TRPZ_PrintServiceContext context, UserManager userManager) { _context = context; _userManager = userManager; } + public IList Orders { get; set; } + public async Task OnGet(string? type) { type ??= "all"; diff --git a/TRPZ_PrintService/Pages/ManageStaff.cshtml.cs b/TRPZ_PrintService/Pages/ManageStaff.cshtml.cs index 1d48df8..76e7cd5 100644 --- a/TRPZ_PrintService/Pages/ManageStaff.cshtml.cs +++ b/TRPZ_PrintService/Pages/ManageStaff.cshtml.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -13,15 +12,7 @@ namespace TRPZ_PrintService.Pages public class ManageStaff : PageModel { private TRPZ_PrintServiceContext _context; - private UserManager _userManager; - - public IList UsersRoles { get; set; } - - public class UserRole - { - public TRPZ_PrintServiceUser user { get; set; } - public IList roles { get; set; } - } + private readonly UserManager _userManager; public ManageStaff(TRPZ_PrintServiceContext context, UserManager userManager) @@ -30,6 +21,8 @@ public ManageStaff(TRPZ_PrintServiceContext context, UserManager UsersRoles { get; set; } + public async Task OnGet() { var users = _userManager.Users.OrderBy(user => user.Id).ToList(); @@ -39,7 +32,7 @@ public async Task OnGet() { var r = _userManager.GetRolesAsync(user); r.Wait(); - UsersRoles.Add(new UserRole() + UsersRoles.Add(new UserRole { roles = r.Result, user = user @@ -82,5 +75,11 @@ public async Task OnPostDelete(string userId) return new RedirectToPageResult("/ManageStaff", ""); } + + public class UserRole + { + public TRPZ_PrintServiceUser user { get; set; } + public IList roles { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Pages/ModelInOrder.cshtml.cs b/TRPZ_PrintService/Pages/ModelInOrder.cshtml.cs index 3bd8dc3..dc41e21 100644 --- a/TRPZ_PrintService/Pages/ModelInOrder.cshtml.cs +++ b/TRPZ_PrintService/Pages/ModelInOrder.cshtml.cs @@ -15,26 +15,18 @@ namespace TRPZ_PrintService.Pages { public class ModelInOrderPage : PageModel { - private TRPZ_PrintServiceContext _context; - private IWebHostEnvironment _environment; + private readonly TRPZ_PrintServiceContext _context; + private readonly IWebHostEnvironment _environment; - [BindProperty] public Order order { get; set; } - public class FormModel + public ModelInOrderPage(TRPZ_PrintServiceContext context, IWebHostEnvironment environment) { - public double Scale { get; set; } - public bool HasSolubleSupports { get; set; } - public int PostProcessingId { get; set; } - public string Description { get; set; } - - public int InfillPercentage { get; set; } - public int Layerheight { get; set; } - public int NozzleDiameter { get; set; } - - public int PrinterId { get; set; } - public int MaterialId { get; set; } + _context = context; + _environment = environment; } + [BindProperty] public Order order { get; set; } + [BindProperty] public FormModel Fmodel { get; set; } public SelectList Printers { get; set; } @@ -42,13 +34,6 @@ public class FormModel public SelectList PostProcessings { get; set; } [Required] [BindProperty] public IFormFile Upload { get; set; } - - public ModelInOrderPage(TRPZ_PrintServiceContext context, IWebHostEnvironment environment) - { - _context = context; - _environment = environment; - } - public IActionResult OnGet(int? id) { if (id == null) return NotFound(); @@ -92,14 +77,14 @@ public async Task OnPostCreate(int id) await Upload.CopyToAsync(fileStream); } - var ms = new ModelSettings() + var ms = new ModelSettings { InfillPercentage = Fmodel.InfillPercentage, LayerHeight = Fmodel.Layerheight, NozzleDiameter = Fmodel.NozzleDiameter }; - var m = new Model3D() + var m = new Model3D { Description = Fmodel.Description, FilePath = uploadFileName @@ -109,7 +94,7 @@ public async Task OnPostCreate(int id) var material = await _context.Materials.FindAsync(Fmodel.MaterialId); var pp = await _context.PostProcessings.FindAsync(Fmodel.PostProcessingId); - var mio = new ModelInOrder() + var mio = new ModelInOrder { Manager = null, Material = material, @@ -127,5 +112,20 @@ public async Task OnPostCreate(int id) return new RedirectToPageResult("/ModelInOrder", "", new {id}); } + + public class FormModel + { + public double Scale { get; set; } + public bool HasSolubleSupports { get; set; } + public int PostProcessingId { get; set; } + public string Description { get; set; } + + public int InfillPercentage { get; set; } + public int Layerheight { get; set; } + public int NozzleDiameter { get; set; } + + public int PrinterId { get; set; } + public int MaterialId { get; set; } + } } } \ No newline at end of file diff --git a/TRPZ_PrintService/Pages/MyOrders.cshtml b/TRPZ_PrintService/Pages/MyOrders.cshtml index f31ef87..ebfcbe7 100644 --- a/TRPZ_PrintService/Pages/MyOrders.cshtml +++ b/TRPZ_PrintService/Pages/MyOrders.cshtml @@ -1,5 +1,4 @@ @page -@using System.Collections @using TRPZ_PrintService.Data @model TRPZ_PrintService.Pages.MyOrders diff --git a/TRPZ_PrintService/Pages/MyOrders.cshtml.cs b/TRPZ_PrintService/Pages/MyOrders.cshtml.cs index 0b48124..1882233 100644 --- a/TRPZ_PrintService/Pages/MyOrders.cshtml.cs +++ b/TRPZ_PrintService/Pages/MyOrders.cshtml.cs @@ -3,27 +3,24 @@ using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; using TRPZ_PrintService.Data; - namespace TRPZ_PrintService.Pages { public class MyOrders : PageModel { - private TRPZ_PrintServiceContext _context; - - [BindProperty] public List Orders { get; set; } + private readonly TRPZ_PrintServiceContext _context; public MyOrders(TRPZ_PrintServiceContext context) { _context = context; } + [BindProperty] public List Orders { get; set; } + public void OnGet(string? id) { id ??= User.FindFirstValue(ClaimTypes.NameIdentifier); diff --git a/TRPZ_PrintService/Pages/Privacy.cshtml.cs b/TRPZ_PrintService/Pages/Privacy.cshtml.cs index 947ad6d..9a611c8 100644 --- a/TRPZ_PrintService/Pages/Privacy.cshtml.cs +++ b/TRPZ_PrintService/Pages/Privacy.cshtml.cs @@ -1,10 +1,5 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace TRPZ_PrintService.Pages { diff --git a/TRPZ_PrintService/Pages/Shared/_LoginPartial.cshtml b/TRPZ_PrintService/Pages/Shared/_LoginPartial.cshtml index 882f8cd..140d772 100644 --- a/TRPZ_PrintService/Pages/Shared/_LoginPartial.cshtml +++ b/TRPZ_PrintService/Pages/Shared/_LoginPartial.cshtml @@ -1,6 +1,5 @@ -@using Microsoft.AspNetCore.Identity -@using TRPZ_PrintService.Areas.Identity.Data - +@using TRPZ_PrintService.Areas.Identity.Data +@using Microsoft.AspNetCore.Identity @inject SignInManager SignInManager @inject UserManager UserManager diff --git a/TRPZ_PrintService/Program.cs b/TRPZ_PrintService/Program.cs index 5d2cd7a..d851007 100644 --- a/TRPZ_PrintService/Program.cs +++ b/TRPZ_PrintService/Program.cs @@ -1,11 +1,5 @@ using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace TRPZ_PrintService { diff --git a/TRPZ_PrintService/Startup.cs b/TRPZ_PrintService/Startup.cs index 29a899a..3f0edbb 100644 --- a/TRPZ_PrintService/Startup.cs +++ b/TRPZ_PrintService/Startup.cs @@ -1,14 +1,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; namespace TRPZ_PrintService {