diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3efd347..39c0beb 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -47,7 +47,6 @@ jobs: env: ConnectionStrings.DefaultConnection: ${{ secrets.connectionstring }} Email.Password: ${{ secrets.email_password }} - Email.AdminEmail: ${{ secrets.admin_email }} - name: Create app_offline file if: startsWith(github.ref, 'refs/tags/v') shell: pwsh diff --git a/src/Server/DynamoLeagueBlazor.Server.csproj b/src/Server/DynamoLeagueBlazor.Server.csproj index c070b7e..ad1b331 100644 --- a/src/Server/DynamoLeagueBlazor.Server.csproj +++ b/src/Server/DynamoLeagueBlazor.Server.csproj @@ -29,8 +29,8 @@ - + diff --git a/src/Server/Infrastructure/EmailSender.cs b/src/Server/Infrastructure/EmailSender.cs index 8f48de1..bdadb30 100644 --- a/src/Server/Infrastructure/EmailSender.cs +++ b/src/Server/Infrastructure/EmailSender.cs @@ -55,5 +55,5 @@ public class EmailSettings public string SenderName { get; set; } = null!; public string Sender { get; set; } = null!; public string Password { get; set; } = null!; - public string AdminEmail { get; set; } + public string AdminEmail { get; set; } = null!; } diff --git a/src/Server/Program.cs b/src/Server/Program.cs index c92bb85..edee429 100644 --- a/src/Server/Program.cs +++ b/src/Server/Program.cs @@ -29,23 +29,8 @@ .MinimumLevel.Override("System", LogEventLevel.Warning) .MinimumLevel.Override("Duende", LogEventLevel.Error) .Enrich.FromLogContext() - .Enrich.WithProperty("Environment", builder.Environment.EnvironmentName); - - builder.Services.Configure(builder.Configuration.GetSection(EmailSettings.Email)) - .AddSingleton(s => s.GetRequiredService>().Value); - - if (builder.Environment.IsProduction()) - { - builder.Services.AddSingleton(); - - var emailSettings = builder.Services.BuildServiceProvider().GetRequiredService(); - loggerConfiguration.WriteTo.Email(emailSettings.Sender, emailSettings.AdminEmail, mailServer: emailSettings.MailServer, restrictedToMinimumLevel: LogEventLevel.Error, mailSubject: "An error occured on Dynamo League."); - } - else - { - builder.Services.AddSingleton(); - loggerConfiguration.WriteTo.Trace(); - } + .Enrich.WithProperty("Environment", builder.Environment.EnvironmentName) + .WriteTo.File(".logs/log.log", rollingInterval: RollingInterval.Day); Log.Logger = loggerConfiguration.CreateLogger(); @@ -99,6 +84,18 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); + builder.Services.Configure(builder.Configuration.GetSection(EmailSettings.Email)) + .AddSingleton(s => s.GetRequiredService>().Value); + + if (builder.Environment.IsProduction()) + { + builder.Services.AddSingleton(); + } + else + { + builder.Services.AddSingleton(); + } + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/src/Server/appsettings.json b/src/Server/appsettings.json index 6974f49..f965f64 100644 --- a/src/Server/appsettings.json +++ b/src/Server/appsettings.json @@ -8,8 +8,7 @@ "MailPort": 25, "SenderName": "Dynamo League - Fantasy Football", "Sender": "postmaster@dynamoleague.com", - "Password": "", - "AdminEmail": "" + "Password": "" }, "IdentityServer": { "Clients": { diff --git a/src/Shared/Features/Admin/AddPlayer.cs b/src/Shared/Features/Admin/AddPlayer.cs index 0e39e58..4116bca 100644 --- a/src/Shared/Features/Admin/AddPlayer.cs +++ b/src/Shared/Features/Admin/AddPlayer.cs @@ -8,8 +8,8 @@ namespace DynamoLeagueBlazor.Shared.Features.Admin; public class AddPlayerRequest { - public string Name { get; set; } - public string Position { get; set; } + public string Name { get; set; } = null!; + public string Position { get; set; } = null!; public int TeamId { get; set; } public int ContractValue { get; set; } } @@ -21,7 +21,7 @@ public class TeamNameListResult public class TeamNameItem { public int Id { get; set; } - public string Name { get; set; } + public string Name { get; set; } = null!; } } @@ -54,8 +54,8 @@ public AddPlayerRequestValidator(IPlayerHeadshotService playerHeadshotService) public class PlayerPreviewRequest { - public string Name { get; set; } - public string Position { get; set; } + public string Name { get; set; } = null!; + public string Position { get; set; } = null!; } public class PlayerPreviewRequestValidator : AbstractValidator diff --git a/src/Shared/Features/Admin/Users/Delete.cs b/src/Shared/Features/Admin/Users/Delete.cs index 5a1c720..1915c90 100644 --- a/src/Shared/Features/Admin/Users/Delete.cs +++ b/src/Shared/Features/Admin/Users/Delete.cs @@ -2,5 +2,5 @@ public class DeleteUserRequest { - public string UserId { get; set; } + public string UserId { get; set; } = null!; } diff --git a/src/Shared/Features/Admin/Users/List.cs b/src/Shared/Features/Admin/Users/List.cs index 4d2ea9f..0285fd0 100644 --- a/src/Shared/Features/Admin/Users/List.cs +++ b/src/Shared/Features/Admin/Users/List.cs @@ -6,9 +6,9 @@ public class UserListResult public class UserItem { - public string Id { get; set; } - public string Team { get; set; } - public string Email { get; set; } + public string Id { get; set; } = null!; + public string Team { get; set; } = null!; + public string Email { get; set; } = null!; public bool EmailConfirmed { get; set; } } } diff --git a/src/Shared/Features/AsyncAbstractValidator.cs b/src/Shared/Features/AsyncAbstractValidator.cs index 0144a65..da9991c 100644 --- a/src/Shared/Features/AsyncAbstractValidator.cs +++ b/src/Shared/Features/AsyncAbstractValidator.cs @@ -12,7 +12,7 @@ namespace DynamoLeagueBlazor.Shared.Helpers; /// public abstract class AsyncAbstractValidator : AbstractValidator { - private Task _validateTask; + private Task _validateTask = null!; public override Task ValidateAsync(ValidationContext context, CancellationToken cancellation = default) => _validateTask = base.ValidateAsync(context, cancellation); @@ -25,6 +25,6 @@ public override ValidationResult Validate(ValidationContext context) } public Task WaitForValidateAsync() - => _validateTask ?? Task.FromResult(null); + => _validateTask ?? Task.FromResult(null!); } \ No newline at end of file diff --git a/src/Shared/Features/Dashboard/TopOffenders.cs b/src/Shared/Features/Dashboard/TopOffenders.cs index 6e00d93..64f6789 100644 --- a/src/Shared/Features/Dashboard/TopOffenders.cs +++ b/src/Shared/Features/Dashboard/TopOffenders.cs @@ -8,9 +8,9 @@ public class TopOffendersResult public class PlayerItem : IRankedItem { - public string ImageUrl { get; set; } - public string Name { get; set; } - public string Amount { get; set; } + public string ImageUrl { get; set; } = null!; + public string Name { get; set; } = null!; + public string Amount { get; set; } = null!; } } diff --git a/src/Shared/Features/Dashboard/TopTeamFines.cs b/src/Shared/Features/Dashboard/TopTeamFines.cs index 7a7a5f6..0785ad7 100644 --- a/src/Shared/Features/Dashboard/TopTeamFines.cs +++ b/src/Shared/Features/Dashboard/TopTeamFines.cs @@ -8,9 +8,9 @@ public class TopTeamFinesResult public class TeamItem : IRankedItem { - public string ImageUrl { get; set; } - public string Name { get; set; } - public string Amount { get; set; } + public string ImageUrl { get; set; } = null!; + public string Name { get; set; } = null!; + public string Amount { get; set; } = null!; } } diff --git a/src/Shared/Features/Fines/List.cs b/src/Shared/Features/Fines/List.cs index 3549bb1..3fee1e9 100644 --- a/src/Shared/Features/Fines/List.cs +++ b/src/Shared/Features/Fines/List.cs @@ -7,13 +7,13 @@ public class FineListResult public class FineItem { public int Id { get; set; } - public string PlayerHeadShotUrl { get; set; } - public string PlayerName { get; set; } - public string TeamName { get; set; } - public string TeamLogoUrl { get; set; } - public string Reason { get; set; } + public string PlayerHeadShotUrl { get; set; } = null!; + public string PlayerName { get; set; } = null!; + public string TeamName { get; set; } = null!; + public string TeamLogoUrl { get; set; } = null!; + public string Reason { get; set; } = null!; public decimal Amount { get; set; } - public string Status { get; set; } + public string Status { get; set; } = null!; } } diff --git a/src/Shared/Features/FreeAgents/Detail.cs b/src/Shared/Features/FreeAgents/Detail.cs index 187798c..7635e33 100644 --- a/src/Shared/Features/FreeAgents/Detail.cs +++ b/src/Shared/Features/FreeAgents/Detail.cs @@ -2,19 +2,19 @@ public class FreeAgentDetailResult { - public string Name { get; set; } - public string Position { get; set; } - public string HeadShotUrl { get; set; } - public string Team { get; set; } - public string EndOfFreeAgency { get; set; } + public string Name { get; set; } = null!; + public string Position { get; set; } = null!; + public string HeadShotUrl { get; set; } = null!; + public string Team { get; set; } = null!; + public string EndOfFreeAgency { get; set; } = null!; public IEnumerable Bids { get; set; } = Enumerable.Empty(); public class BidItem { - public string Team { get; set; } - public string Amount { get; set; } - public string CreatedOn { get; set; } + public string Team { get; set; } = null!; + public string Amount { get; set; } = null!; + public string CreatedOn { get; set; } = null!; } } diff --git a/src/Shared/Features/FreeAgents/List.cs b/src/Shared/Features/FreeAgents/List.cs index f9ab95e..0cec9ed 100644 --- a/src/Shared/Features/FreeAgents/List.cs +++ b/src/Shared/Features/FreeAgents/List.cs @@ -2,15 +2,15 @@ public class FreeAgentListResult { - public List FreeAgents { get; set; } + public List FreeAgents { get; set; } = new(); public class FreeAgentItem { public int Id { get; set; } - public string Name { get; set; } - public string Position { get; set; } - public string Team { get; set; } - public string HeadShotUrl { get; set; } + public string Name { get; set; } = null!; + public string Position { get; set; } = null!; + public string Team { get; set; } = null!; + public string HeadShotUrl { get; set; } = null!; public DateTime BiddingEnds { get; set; } public int HighestBid { get; set; } public bool CurrentUserIsHighestBidder { get; set; } diff --git a/src/Shared/Features/OfferMatching/List.cs b/src/Shared/Features/OfferMatching/List.cs index 9e53d8e..23d63fe 100644 --- a/src/Shared/Features/OfferMatching/List.cs +++ b/src/Shared/Features/OfferMatching/List.cs @@ -7,10 +7,10 @@ public class OfferMatchingListResult public class OfferMatchingItem { public int Id { get; set; } - public string Name { get; set; } - public string Position { get; set; } - public string HeadShotUrl { get; set; } - public string OfferingTeam { get; set; } + public string Name { get; set; } = null!; + public string Position { get; set; } = null!; + public string HeadShotUrl { get; set; } = null!; + public string OfferingTeam { get; set; } = null!; public int Offer { get; set; } } } diff --git a/src/Shared/Features/Players/AddFine.cs b/src/Shared/Features/Players/AddFine.cs index f68df74..c313dcb 100644 --- a/src/Shared/Features/Players/AddFine.cs +++ b/src/Shared/Features/Players/AddFine.cs @@ -6,7 +6,7 @@ namespace DynamoLeagueBlazor.Shared.Features.Players; public class AddFineRequest { public int PlayerId { get; set; } - public string FineReason { get; set; } + public string FineReason { get; set; } = null!; } public class AddFineRequestValidator : AbstractValidator diff --git a/src/Shared/Features/Players/List.cs b/src/Shared/Features/Players/List.cs index 1dd6b51..5c1aa2e 100644 --- a/src/Shared/Features/Players/List.cs +++ b/src/Shared/Features/Players/List.cs @@ -7,10 +7,10 @@ public class PlayerListResult public class PlayerItem { public int Id { get; set; } - public string HeadShotUrl { get; set; } - public string Name { get; set; } - public string Position { get; set; } - public string Team { get; set; } + public string HeadShotUrl { get; set; } = null!; + public string Name { get; set; } = null!; + public string Position { get; set; } = null!; + public string Team { get; set; } = null!; public int ContractValue { get; set; } public int YearContractExpires { get; set; } } diff --git a/src/Shared/Features/Teams/Detail.cs b/src/Shared/Features/Teams/Detail.cs index d8a4b47..9c5fc93 100644 --- a/src/Shared/Features/Teams/Detail.cs +++ b/src/Shared/Features/Teams/Detail.cs @@ -2,9 +2,9 @@ public class TeamDetailResult { - public string LogoUrl { get; set; } - public string Name { get; set; } - public string CapSpace { get; set; } + public string LogoUrl { get; set; } = null!; + public string Name { get; set; } = null!; + public string CapSpace { get; set; } = null!; public List RosteredPlayers { get; set; } = new List(); public List UnrosteredPlayers { get; set; } = new List(); public List UnsignedPlayers { get; set; } = new List(); @@ -13,9 +13,9 @@ public class TeamDetailResult public class PlayerItem { public int Id { get; set; } - public string HeadShotUrl { get; set; } - public string Name { get; set; } - public string Position { get; set; } + public string HeadShotUrl { get; set; } = null!; + public string Name { get; set; } = null!; + public string Position { get; set; } = null!; public int ContractValue { get; set; } public int? YearContractExpires { get; set; } } diff --git a/src/Shared/Features/Teams/List.cs b/src/Shared/Features/Teams/List.cs index aed70e3..106feea 100644 --- a/src/Shared/Features/Teams/List.cs +++ b/src/Shared/Features/Teams/List.cs @@ -7,12 +7,12 @@ public class TeamListResult public class TeamItem { public int Id { get; set; } - public string LogoUrl { get; set; } - public string Name { get; set; } - public string RosteredPlayerCount { get; set; } - public string UnrosteredPlayerCount { get; set; } - public string UnsignedPlayerCount { get; set; } - public string CapSpace { get; set; } + public string LogoUrl { get; set; } = null!; + public string Name { get; set; } = null!; + public string RosteredPlayerCount { get; set; } = null!; + public string UnrosteredPlayerCount { get; set; } = null!; + public string UnsignedPlayerCount { get; set; } = null!; + public string CapSpace { get; set; } = null!; } }