From 19a5dde1acea8ee51aab3cb8ea6645ce67fce9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borja=20Garc=C3=ADa=20Rodr=C3=ADguez?= Date: Wed, 16 Dec 2020 11:07:22 +0100 Subject: [PATCH 1/2] net5 --- src/Services/Identity/Identity.API/Dockerfile | 4 +- .../Identity/Identity.API/Identity.API.csproj | 2 +- src/Services/Identity/Identity.API/Program.cs | 164 ++++++++---------- 3 files changed, 80 insertions(+), 90 deletions(-) diff --git a/src/Services/Identity/Identity.API/Dockerfile b/src/Services/Identity/Identity.API/Dockerfile index 0333e9f2e2..72d419d298 100644 --- a/src/Services/Identity/Identity.API/Dockerfile +++ b/src/Services/Identity/Identity.API/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base +FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index 426b5d4619..6245700d25 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 aspnet-eShopOnContainers.Identity-90487118-103c-4ff0-b9da-e5e26f7ab0c5 ..\..\..\..\docker-compose.dcproj false diff --git a/src/Services/Identity/Identity.API/Program.cs b/src/Services/Identity/Identity.API/Program.cs index 1d058faf92..9096806210 100644 --- a/src/Services/Identity/Identity.API/Program.cs +++ b/src/Services/Identity/Identity.API/Program.cs @@ -1,6 +1,7 @@ using IdentityServer4.EntityFramework.DbContexts; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.eShopOnContainers.Services.Identity.API; using Microsoft.eShopOnContainers.Services.Identity.API.Data; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -11,103 +12,92 @@ using System; using System.IO; -namespace Microsoft.eShopOnContainers.Services.Identity.API -{ - public class Program - { - public static readonly string Namespace = typeof(Program).Namespace; - public static readonly string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); - - public static int Main(string[] args) - { - var configuration = GetConfiguration(); - - Log.Logger = CreateSerilogLogger(configuration); - - try - { - Log.Information("Configuring web host ({ApplicationContext})...", AppName); - var host = BuildWebHost(configuration, args); +string Namespace = typeof(Startup).Namespace; +string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); - Log.Information("Applying migrations ({ApplicationContext})...", AppName); - host.MigrateDbContext((_, __) => { }) - .MigrateDbContext((context, services) => - { - var env = services.GetService(); - var logger = services.GetService>(); - var settings = services.GetService>(); +var configuration = GetConfiguration(); - new ApplicationDbContextSeed() - .SeedAsync(context, env, logger, settings) - .Wait(); - }) - .MigrateDbContext((context, services) => - { - new ConfigurationDbContextSeed() - .SeedAsync(context, configuration) - .Wait(); - }); +Log.Logger = CreateSerilogLogger(configuration); - Log.Information("Starting web host ({ApplicationContext})...", AppName); - host.Run(); +try +{ + Log.Information("Configuring web host ({ApplicationContext})...", AppName); + var host = BuildWebHost(configuration, args); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName); - return 1; - } - finally - { - Log.CloseAndFlush(); - } - } + Log.Information("Applying migrations ({ApplicationContext})...", AppName); + host.MigrateDbContext((_, __) => { }) + .MigrateDbContext((context, services) => + { + var env = services.GetService(); + var logger = services.GetService>(); + var settings = services.GetService>(); + + new ApplicationDbContextSeed() + .SeedAsync(context, env, logger, settings) + .Wait(); + }) + .MigrateDbContext((context, services) => + { + new ConfigurationDbContextSeed() + .SeedAsync(context, configuration) + .Wait(); + }); - private static IWebHost BuildWebHost(IConfiguration configuration, string[] args) => - WebHost.CreateDefaultBuilder(args) - .CaptureStartupErrors(false) - .ConfigureAppConfiguration(x => x.AddConfiguration(configuration)) - .UseStartup() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseSerilog() - .Build(); + Log.Information("Starting web host ({ApplicationContext})...", AppName); + host.Run(); - private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) - { - var seqServerUrl = configuration["Serilog:SeqServerUrl"]; - var logstashUrl = configuration["Serilog:LogstashgUrl"]; - return new LoggerConfiguration() - .MinimumLevel.Verbose() - .Enrich.WithProperty("ApplicationContext", AppName) - .Enrich.FromLogContext() - .WriteTo.Console() - .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl) - .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://localhost:8080" : logstashUrl) - .ReadFrom.Configuration(configuration) - .CreateLogger(); - } + return 0; +} +catch (Exception ex) +{ + Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName); + return 1; +} +finally +{ + Log.CloseAndFlush(); +} - private static IConfiguration GetConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddEnvironmentVariables(); +IWebHost BuildWebHost(IConfiguration configuration, string[] args) => + WebHost.CreateDefaultBuilder(args) + .CaptureStartupErrors(false) + .ConfigureAppConfiguration(x => x.AddConfiguration(configuration)) + .UseStartup() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseSerilog() + .Build(); - var config = builder.Build(); +Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) +{ + var seqServerUrl = configuration["Serilog:SeqServerUrl"]; + var logstashUrl = configuration["Serilog:LogstashgUrl"]; + return new LoggerConfiguration() + .MinimumLevel.Verbose() + .Enrich.WithProperty("ApplicationContext", AppName) + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl) + .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://localhost:8080" : logstashUrl) + .ReadFrom.Configuration(configuration) + .CreateLogger(); +} - if (config.GetValue("UseVault", false)) - { - builder.AddAzureKeyVault( - $"https://{config["Vault:Name"]}.vault.azure.net/", - config["Vault:ClientId"], - config["Vault:ClientSecret"]); - } +IConfiguration GetConfiguration() +{ + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddEnvironmentVariables(); - return builder.Build(); - } + var config = builder.Build(); + if (config.GetValue("UseVault", false)) + { + builder.AddAzureKeyVault( + $"https://{config["Vault:Name"]}.vault.azure.net/", + config["Vault:ClientId"], + config["Vault:ClientSecret"]); } -} + return builder.Build(); +} \ No newline at end of file From 1fe0121e844e6ce1aeec58cc9b7449c5f07b37c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borja=20Garc=C3=ADa=20Rodr=C3=ADguez?= Date: Wed, 16 Dec 2020 12:13:14 +0100 Subject: [PATCH 2/2] record types --- .../AccountViewModels/ConsentInputModel.cs | 10 +++--- .../AccountViewModels/ConsentViewModel.cs | 32 +++++++++---------- .../ForgotPasswordViewModel.cs | 4 +-- .../AccountViewModels/LoggedOutViewModel.cs | 8 ++--- .../AccountViewModels/LoginViewModel.cs | 2 +- .../AccountViewModels/LogoutViewModel.cs | 2 +- .../AccountViewModels/RegisterViewModel.cs | 10 +++--- .../ResetPasswordViewModel.cs | 10 +++--- .../AccountViewModels/SendCodeViewModel.cs | 10 +++--- .../AccountViewModels/VerifyCodeViewModel.cs | 12 +++---- .../Identity.API/Models/ErrorViewModel.cs | 2 +- .../AddPhoneNumberViewModel.cs | 4 +-- .../ChangePasswordViewModel.cs | 8 ++--- .../ConfigureTwoFactorViewModel.cs | 6 ++-- .../ManageViewModels/FactorViewModel.cs | 4 +-- .../Models/ManageViewModels/IndexViewModel.cs | 12 +++---- .../ManageViewModels/SetPasswordViewModel.cs | 6 ++-- .../VerifyPhoneNumberViewModel.cs | 6 ++-- 18 files changed, 73 insertions(+), 75 deletions(-) diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs index 633f37b898..739d833aad 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs @@ -2,11 +2,11 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class ConsentInputModel + public record ConsentInputModel { - public string Button { get; set; } - public IEnumerable ScopesConsented { get; set; } - public bool RememberConsent { get; set; } - public string ReturnUrl { get; set; } + public string Button { get; init; } + public IEnumerable ScopesConsented { get; init; } + public bool RememberConsent { get; init; } + public string ReturnUrl { get; init; } } } \ No newline at end of file diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs index c010f636fb..10dc8548ab 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs @@ -1,12 +1,10 @@ - - -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using IdentityServer4.Models; namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class ConsentViewModel : ConsentInputModel + public record ConsentViewModel : ConsentInputModel { public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, Client client, Resources resources) { @@ -24,16 +22,16 @@ public ConsentViewModel(ConsentInputModel model, string returnUrl, Authorization ResourceScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => new ScopeViewModel(x, ScopesConsented.Contains(x.Name) || model == null)).ToArray(); } - public string ClientName { get; set; } - public string ClientUrl { get; set; } - public string ClientLogoUrl { get; set; } - public bool AllowRememberConsent { get; set; } + public string ClientName { get; init; } + public string ClientUrl { get; init; } + public string ClientLogoUrl { get; init; } + public bool AllowRememberConsent { get; init; } - public IEnumerable IdentityScopes { get; set; } - public IEnumerable ResourceScopes { get; set; } + public IEnumerable IdentityScopes { get; init; } + public IEnumerable ResourceScopes { get; init; } } - public class ScopeViewModel + public record ScopeViewModel { public ScopeViewModel(Scope scope, bool check) { @@ -55,11 +53,11 @@ public ScopeViewModel(IdentityResource identity, bool check) Checked = check || identity.Required; } - public string Name { get; set; } - public string DisplayName { get; set; } - public string Description { get; set; } - public bool Emphasize { get; set; } - public bool Required { get; set; } - public bool Checked { get; set; } + public string Name { get; init; } + public string DisplayName { get; init; } + public string Description { get; init; } + public bool Emphasize { get; init; } + public bool Required { get; init; } + public bool Checked { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs index f5dd3ab610..ad661c65fc 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs @@ -2,10 +2,10 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class ForgotPasswordViewModel + public record ForgotPasswordViewModel { [Required] [EmailAddress] - public string Email { get; set; } + public string Email { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/LoggedOutViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/LoggedOutViewModel.cs index bd7f7c7bb9..eff853f9da 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/LoggedOutViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/LoggedOutViewModel.cs @@ -1,9 +1,9 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class LoggedOutViewModel + public record LoggedOutViewModel { - public string PostLogoutRedirectUri { get; set; } - public string ClientName { get; set; } - public string SignOutIframeUrl { get; set; } + public string PostLogoutRedirectUri { get; init; } + public string ClientName { get; init; } + public string SignOutIframeUrl { get; init; } } } \ No newline at end of file diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs index 3b1926cc2d..97ef19abad 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs @@ -2,7 +2,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class LoginViewModel + public record LoginViewModel { [Required] [EmailAddress] diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/LogoutViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/LogoutViewModel.cs index d81dcd6ac4..f9d23c629c 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/LogoutViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/LogoutViewModel.cs @@ -1,6 +1,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class LogoutViewModel + public record LogoutViewModel { public string LogoutId { get; set; } } diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs index df97bb9650..00fc05d4bb 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs @@ -2,24 +2,24 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class RegisterViewModel + public record RegisterViewModel { [Required] [EmailAddress] [Display(Name = "Email")] - public string Email { get; set; } + public string Email { get; init; } [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; } + public string Password { get; init; } [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 ConfirmPassword { get; init; } - public ApplicationUser User { get; set; } + public ApplicationUser User { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs index 57edc44c34..50c5b585fa 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs @@ -2,22 +2,22 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class ResetPasswordViewModel + public record ResetPasswordViewModel { [Required] [EmailAddress] - public string Email { get; set; } + public string Email { get; init; } [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; } + public string Password { get; init; } [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 ConfirmPassword { get; init; } - public string Code { get; set; } + public string Code { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs index a6f316c488..35429e9e51 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs @@ -3,14 +3,14 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class SendCodeViewModel + public record SendCodeViewModel { - public string SelectedProvider { get; set; } + public string SelectedProvider { get; init; } - public ICollection Providers { get; set; } + public ICollection Providers { get; init; } - public string ReturnUrl { get; set; } + public string ReturnUrl { get; init; } - public bool RememberMe { get; set; } + public bool RememberMe { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs index 83d075f9ca..e54d6c05b7 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs @@ -2,20 +2,20 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { - public class VerifyCodeViewModel + public record VerifyCodeViewModel { [Required] - public string Provider { get; set; } + public string Provider { get; init; } [Required] - public string Code { get; set; } + public string Code { get; init; } - public string ReturnUrl { get; set; } + public string ReturnUrl { get; init; } [Display(Name = "Remember this browser?")] - public bool RememberBrowser { get; set; } + public bool RememberBrowser { get; init; } [Display(Name = "Remember me?")] - public bool RememberMe { get; set; } + public bool RememberMe { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/ErrorViewModel.cs b/src/Services/Identity/Identity.API/Models/ErrorViewModel.cs index b101bca7a2..a327e7b083 100644 --- a/src/Services/Identity/Identity.API/Models/ErrorViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ErrorViewModel.cs @@ -6,7 +6,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models { - public class ErrorViewModel + public record ErrorViewModel { public ErrorMessage Error { get; set; } } diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs index 2a1cc49d08..878b0440b1 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs @@ -2,11 +2,11 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { - public class AddPhoneNumberViewModel + public record AddPhoneNumberViewModel { [Required] [Phone] [Display(Name = "Phone number")] - public string PhoneNumber { get; set; } + public string PhoneNumber { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs index fa9193c38a..65521429fd 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs @@ -2,22 +2,22 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { - public class ChangePasswordViewModel + public record ChangePasswordViewModel { [Required] [DataType(DataType.Password)] [Display(Name = "Current password")] - public string OldPassword { get; set; } + public string OldPassword { get; init; } [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; } + public string NewPassword { get; init; } [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 string ConfirmPassword { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs index 15cf719faf..a0a7f30bf9 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs @@ -3,10 +3,10 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { - public class ConfigureTwoFactorViewModel + public record ConfigureTwoFactorViewModel { - public string SelectedProvider { get; set; } + public string SelectedProvider { get; init; } - public ICollection Providers { get; set; } + public ICollection Providers { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/FactorViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/FactorViewModel.cs index 4a6d4497ff..b9e6e5d5b5 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/FactorViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/FactorViewModel.cs @@ -1,7 +1,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { - public class FactorViewModel + public record FactorViewModel { - public string Purpose { get; set; } + public string Purpose { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs index b13bc18e35..8d32c8e69a 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs @@ -3,16 +3,16 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { - public class IndexViewModel + public record IndexViewModel { - public bool HasPassword { get; set; } + public bool HasPassword { get; init; } - public IList Logins { get; set; } + public IList Logins { get; init; } - public string PhoneNumber { get; set; } + public string PhoneNumber { get; init; } - public bool TwoFactor { get; set; } + public bool TwoFactor { get; init; } - public bool BrowserRemembered { get; set; } + public bool BrowserRemembered { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs index 9d0711b087..e2f048054a 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs @@ -2,17 +2,17 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { - public class SetPasswordViewModel + public record SetPasswordViewModel { [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; } + public string NewPassword { get; init; } [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 string ConfirmPassword { get; init; } } } diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs index fccf56e4ec..a3c8e5c651 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs @@ -2,14 +2,14 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { - public class VerifyPhoneNumberViewModel + public record VerifyPhoneNumberViewModel { [Required] - public string Code { get; set; } + public string Code { get; init; } [Required] [Phone] [Display(Name = "Phone number")] - public string PhoneNumber { get; set; } + public string PhoneNumber { get; init; } } }