diff --git a/src/EventHub.Domain/Data/EventHubDbMigrationService.cs b/src/EventHub.Domain/Data/EventHubDbMigrationService.cs index b29a92c..fc46d7b 100644 --- a/src/EventHub.Domain/Data/EventHubDbMigrationService.cs +++ b/src/EventHub.Domain/Data/EventHubDbMigrationService.cs @@ -33,9 +33,9 @@ namespace EventHub.Data { try { - if (!await MigrationsFolderExists()) + if (!MigrationsFolderExists()) { - await AddInitialMigration(); + AddInitialMigration(); return; } } @@ -70,14 +70,14 @@ namespace EventHub.Data await _dataSeeder.SeedAsync(); } - private async Task MigrationsFolderExists() + private bool MigrationsFolderExists() { var dbMigrationsProjectFolder = GetDbMigrationsProjectFolderPath(); return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "migrations")); } - private async Task AddInitialMigration() + private void AddInitialMigration() { Logger.LogInformation("Creating initial migration..."); diff --git a/src/EventHub.Web/Helpers/AllowedExtensionsAttribute.cs b/src/EventHub.Web/Helpers/AllowedExtensionsAttribute.cs index df4f997..75467cd 100644 --- a/src/EventHub.Web/Helpers/AllowedExtensionsAttribute.cs +++ b/src/EventHub.Web/Helpers/AllowedExtensionsAttribute.cs @@ -1,3 +1,4 @@ +#nullable enable using System.ComponentModel.DataAnnotations; using System.IO; using System.Linq; @@ -16,16 +17,12 @@ namespace EventHub.Web.Helpers protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) { - if (value == null) - { - return ValidationResult.Success; - } - var file = value as IFormFile; - var extension = Path.GetExtension(file.FileName); - if (file.Length > 0 && file != null) + if (file is { Length: > 0 }) { + var extension = Path.GetExtension(file.FileName); + if (!_allowedExtensions.Contains(extension.ToLower())) { return new ValidationResult("This file extension is not allowed. Allowed extensions: " + string.Join(",", _allowedExtensions)); diff --git a/src/EventHub.Web/Pages/Events/Detail.cshtml.cs b/src/EventHub.Web/Pages/Events/Detail.cshtml.cs index 807babb..f235227 100644 --- a/src/EventHub.Web/Pages/Events/Detail.cshtml.cs +++ b/src/EventHub.Web/Pages/Events/Detail.cshtml.cs @@ -8,7 +8,7 @@ namespace EventHub.Web.Pages.Events public class DetailPageModel : EventHubPageModel { [BindProperty(SupportsGet = true)] - public string Url { get; set; } + public new string Url { get; set; } public bool IsEventOwner { get; set; } @@ -40,7 +40,7 @@ namespace EventHub.Web.Pages.Events { url = Event.Url } - ) + )! ); } diff --git a/src/EventHub.Web/Pages/Events/Edit.cshtml.cs b/src/EventHub.Web/Pages/Events/Edit.cshtml.cs index 0e7441e..2637acb 100644 --- a/src/EventHub.Web/Pages/Events/Edit.cshtml.cs +++ b/src/EventHub.Web/Pages/Events/Edit.cshtml.cs @@ -22,7 +22,7 @@ namespace EventHub.Web.Pages.Events public class EditPageModel : EventHubPageModel { [BindProperty(SupportsGet = true)] - public string Url { get; set; } + public new string Url { get; set; } [BindProperty] public EditEventViewModel Event { get; set; } diff --git a/src/EventHub.Web/Pages/User.cshtml.cs b/src/EventHub.Web/Pages/User.cshtml.cs index d91b492..cc03cc2 100644 --- a/src/EventHub.Web/Pages/User.cshtml.cs +++ b/src/EventHub.Web/Pages/User.cshtml.cs @@ -24,7 +24,7 @@ namespace EventHub.Web.Pages _organizationAppService = organizationAppService; } - public UserDto User { get; set; } + public new UserDto User { get; set; } public async Task OnGetAsync(string userName) {