Browse Source

Fix build warnings

pull/71/head
Berkan Sasmaz 5 years ago
parent
commit
297de1f82c
  1. 8
      src/EventHub.Domain/Data/EventHubDbMigrationService.cs
  2. 11
      src/EventHub.Web/Helpers/AllowedExtensionsAttribute.cs
  3. 4
      src/EventHub.Web/Pages/Events/Detail.cshtml.cs
  4. 2
      src/EventHub.Web/Pages/Events/Edit.cshtml.cs
  5. 2
      src/EventHub.Web/Pages/User.cshtml.cs

8
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<bool> 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...");

11
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));

4
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
}
)
)!
);
}

2
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; }

2
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<IActionResult> OnGetAsync(string userName)
{

Loading…
Cancel
Save