Skip to content

Commit

Permalink
feat: update dependencies and framework version
Browse files Browse the repository at this point in the history
* implicit usings
* file-scoped namespaces
* nuget packages
* latest dotnet version
  • Loading branch information
alsami authored and alsami committed Mar 31, 2022
1 parent 99138eb commit 25fc203
Show file tree
Hide file tree
Showing 172 changed files with 2,911 additions and 3,300 deletions.
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project>
<PropertyGroup>
<LangVersion>9.0</LangVersion>
<LangVersion>10.0</LangVersion>
<Nullable>Enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.101",
"version": "6.0.201",
"rollForward": "latestFeature"
}
}
19 changes: 9 additions & 10 deletions src/Covid19Api.AutoMapper/CountryStatisticsAggregateProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
using Covid19Api.Domain;
using Covid19Api.Presentation.Response;

namespace Covid19Api.AutoMapper
namespace Covid19Api.AutoMapper;

public class CountryStatisticsAggregateProfile : Profile
{
public class CountryStatisticsAggregateProfile : Profile
public CountryStatisticsAggregateProfile()
{
public CountryStatisticsAggregateProfile()
{
this.CreateMap<CountryStatisticsAggregate, CountryStatisticAggregateDto>()
.ConvertUsing(source => new CountryStatisticAggregateDto(source.Id, source.Country, source.CountryCode,
source.Total, source.New, source.Deaths, source.NewDeaths, source.Recovered, source.Active,
source.Month,
source.Year));
}
this.CreateMap<CountryStatisticsAggregate, CountryStatisticAggregateDto>()
.ConvertUsing(source => new CountryStatisticAggregateDto(source.Id, source.Country, source.CountryCode,
source.Total, source.New, source.Deaths, source.NewDeaths, source.Recovered, source.Active,
source.Month,
source.Year));
}
}
15 changes: 7 additions & 8 deletions src/Covid19Api.AutoMapper/CountryStatisticsProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

// ReSharper disable UnusedMember.Global

namespace Covid19Api.AutoMapper
namespace Covid19Api.AutoMapper;

public class CountryStatisticsProfile : Profile
{
public class CountryStatisticsProfile : Profile
public CountryStatisticsProfile()
{
public CountryStatisticsProfile()
{
this.CreateMap<CountryStatistic, CountryStatisticDto>()
.ConvertUsing(src => new CountryStatisticDto(src.Country, src.CountryCode, src.TotalCases,
src.NewCases, src.TotalDeaths, src.NewDeaths, src.RecoveredCases, src.ActiveCases, src.FetchedAt));
}
this.CreateMap<CountryStatistic, CountryStatisticDto>()
.ConvertUsing(src => new CountryStatisticDto(src.Country, src.CountryCode, src.TotalCases,
src.NewCases, src.TotalDeaths, src.NewDeaths, src.RecoveredCases, src.ActiveCases, src.FetchedAt));
}
}
3 changes: 2 additions & 1 deletion src/Covid19Api.AutoMapper/Covid19Api.AutoMapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="AutoMapper" Version="11.0.1" />
<PackageReference Update="SonarAnalyzer.CSharp" Version="8.37.0.45539" />

</ItemGroup>

Expand Down
15 changes: 7 additions & 8 deletions src/Covid19Api.AutoMapper/GlobalStatisticsAggregateProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
using Covid19Api.Domain;
using Covid19Api.Presentation.Response;

namespace Covid19Api.AutoMapper
namespace Covid19Api.AutoMapper;

public class GlobalStatisticsAggregateProfile : Profile
{
public class GlobalStatisticsAggregateProfile : Profile
public GlobalStatisticsAggregateProfile()
{
public GlobalStatisticsAggregateProfile()
{
this.CreateMap<GlobalStatisticsAggregate, GlobalStatisticAggregateDto>()
.ConstructUsing(source => new GlobalStatisticAggregateDto(source.Id, source.Total, source.Recovered,
source.Deaths, source.Month, source.Year));
}
this.CreateMap<GlobalStatisticsAggregate, GlobalStatisticAggregateDto>()
.ConstructUsing(source => new GlobalStatisticAggregateDto(source.Id, source.Total, source.Recovered,
source.Deaths, source.Month, source.Year));
}
}
15 changes: 7 additions & 8 deletions src/Covid19Api.AutoMapper/GlobalStatisticsProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
// ReSharper disable UnusedType.Global

// ReSharper disable UnusedMember.Global
namespace Covid19Api.AutoMapper
namespace Covid19Api.AutoMapper;

public class GlobalStatisticsProfile : Profile
{
public class GlobalStatisticsProfile : Profile
public GlobalStatisticsProfile()
{
public GlobalStatisticsProfile()
{
this.CreateMap<GlobalStatistics, GlobalStatisticDto>()
.ConvertUsing(src =>
new GlobalStatisticDto(src.Total, src.Recovered, src.Deaths, src.FetchedAt));
}
this.CreateMap<GlobalStatistics, GlobalStatisticDto>()
.ConvertUsing(src =>
new GlobalStatisticDto(src.Total, src.Recovered, src.Deaths, src.FetchedAt));
}
}
15 changes: 7 additions & 8 deletions src/Covid19Api.AutoMapper/VaccinationStatisticProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
using Covid19Api.Domain;
using Covid19Api.Presentation.Response;

namespace Covid19Api.AutoMapper
namespace Covid19Api.AutoMapper;

// ReSharper disable once UnusedType.Global
public class VaccinationStatisticProfile : Profile
{
// ReSharper disable once UnusedType.Global
public class VaccinationStatisticProfile : Profile
public VaccinationStatisticProfile()
{
public VaccinationStatisticProfile()
{
this.CreateMap<VaccinationStatistic, VaccinationStatisticDto>()
.ConvertUsing<VaccinationStatisticToDtoTypeConverter>();
}
this.CreateMap<VaccinationStatistic, VaccinationStatisticDto>()
.ConvertUsing<VaccinationStatisticToDtoTypeConverter>();
}
}
24 changes: 11 additions & 13 deletions src/Covid19Api.AutoMapper/VaccinationStatisticToDtoTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
using System.Linq;
using AutoMapper;
using Covid19Api.Domain;
using Covid19Api.Presentation.Response;

namespace Covid19Api.AutoMapper
namespace Covid19Api.AutoMapper;

public class VaccinationStatisticToDtoTypeConverter : ITypeConverter<VaccinationStatistic, VaccinationStatisticDto>
{
public class VaccinationStatisticToDtoTypeConverter : ITypeConverter<VaccinationStatistic, VaccinationStatisticDto>
public VaccinationStatisticDto Convert(VaccinationStatistic source, VaccinationStatisticDto destination,
ResolutionContext context)
{
public VaccinationStatisticDto Convert(VaccinationStatistic source, VaccinationStatisticDto destination,
ResolutionContext context)
{
var values = source.Values.Select(value => new VaccinationStatisticValueDto(value.LoggedAt,
value.TotalVaccinations, value.PeopleVaccinated, value.PeopleFullyVaccinated,
value.PeopleFullyVaccinatedPerHundred, value.DailyVaccinations,
value.TotalVaccinationsPerHundred, value.PeopleVaccinatedPerHundred,
value.DailyVaccinationsPerMillion));
return new VaccinationStatisticDto(source.Country, source.CountyCode,values.OrderBy(value => value.LoggedAt).ToArray());
}
var values = source.Values.Select(value => new VaccinationStatisticValueDto(value.LoggedAt,
value.TotalVaccinations, value.PeopleVaccinated, value.PeopleFullyVaccinated,
value.PeopleFullyVaccinatedPerHundred, value.DailyVaccinations,
value.TotalVaccinationsPerHundred, value.PeopleVaccinatedPerHundred,
value.DailyVaccinationsPerMillion));
return new VaccinationStatisticDto(source.Country, source.CountyCode,values.OrderBy(value => value.LoggedAt).ToArray());
}
}
4 changes: 4 additions & 0 deletions src/Covid19Api.Constants/Covid19Api.Constants.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Update="SonarAnalyzer.CSharp" Version="8.37.0.45539" />
</ItemGroup>



</Project>
11 changes: 5 additions & 6 deletions src/Covid19Api.Constants/Urls.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace Covid19Api.Constants
namespace Covid19Api.Constants;

public static class Urls
{
public static class Urls
{
// ReSharper disable once S1075
// ReSharper disable once S1075
#pragma warning disable S1075
public const string Covid19WorldometerUrl = "https://worldometers.info/coronavirus";
public const string Covid19WorldometerUrl = "https://worldometers.info/coronavirus";
#pragma warning restore
}
}
84 changes: 41 additions & 43 deletions src/Covid19Api.Domain/CountryStatistic.cs
Original file line number Diff line number Diff line change
@@ -1,68 +1,66 @@
using System;
using System.Security.Cryptography;
using System.Text;

// ReSharper disable UnusedAutoPropertyAccessor.Local
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Local
// ReSharper disable UnusedAutoPropertyAccessor.Global

namespace Covid19Api.Domain
namespace Covid19Api.Domain;

public class CountryStatistic
{
public class CountryStatistic
{
public Guid Id { get; private set; }
public Guid Id { get; private set; }

public string Country { get; private set; }
public string Country { get; private set; }

public string? CountryCode { get; private set; }
public string? CountryCode { get; private set; }

public int TotalCases { get; private set; }
public int TotalCases { get; private set; }

public int NewCases { get; private set; }
public int NewCases { get; private set; }

public int TotalDeaths { get; private set; }
public int TotalDeaths { get; private set; }

public int NewDeaths { get; private set; }
public int NewDeaths { get; private set; }

public int RecoveredCases { get; private set; }
public int RecoveredCases { get; private set; }

public int ActiveCases { get; private set; }
public int ActiveCases { get; private set; }

public DateTime FetchedAt { get; private set; }
public DateTime FetchedAt { get; private set; }

public CountryStatistic(string country, string? countryCode, int totalCases, int newCases, int totalDeaths,
int newDeaths,
int recoveredCases, int activeCases, DateTime fetchedAt)
{
this.Country = country;
this.CountryCode = countryCode;
this.TotalCases = totalCases;
this.NewCases = newCases;
this.TotalDeaths = totalDeaths;
this.NewDeaths = newDeaths;
this.RecoveredCases = recoveredCases;
this.ActiveCases = activeCases;
this.FetchedAt = fetchedAt;
this.Id = this.Generate();
}
public CountryStatistic(string country, string? countryCode, int totalCases, int newCases, int totalDeaths,
int newDeaths,
int recoveredCases, int activeCases, DateTime fetchedAt)
{
this.Country = country;
this.CountryCode = countryCode;
this.TotalCases = totalCases;
this.NewCases = newCases;
this.TotalDeaths = totalDeaths;
this.NewDeaths = newDeaths;
this.RecoveredCases = recoveredCases;
this.ActiveCases = activeCases;
this.FetchedAt = fetchedAt;
this.Id = this.Generate();
}

public bool Empty()
{
return this.TotalCases == 0 && this.NewCases == 0 &&
this.TotalDeaths == 0 && this.NewDeaths == 0 &&
this.RecoveredCases == 0 && this.ActiveCases == 0;
}
public bool Empty()
{
return this.TotalCases == 0 && this.NewCases == 0 &&
this.TotalDeaths == 0 && this.NewDeaths == 0 &&
this.RecoveredCases == 0 && this.ActiveCases == 0;
}

private Guid Generate()
{
using var hasher = MD5.Create();
private Guid Generate()
{
using var hasher = MD5.Create();

var valueToHash =
$"{this.Country}{this.FetchedAt.Date:O}";
var valueToHash =
$"{this.Country}{this.FetchedAt.Date:O}";

var hashed = hasher.ComputeHash(Encoding.UTF8.GetBytes(valueToHash));
var hashed = hasher.ComputeHash(Encoding.UTF8.GetBytes(valueToHash));

return new Guid(hashed);
}
return new Guid(hashed);
}
}
Loading

0 comments on commit 25fc203

Please sign in to comment.