-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking: remove serious-cases property from country-statistics
- Loading branch information
Showing
6 changed files
with
67 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace Covid19Api.Domain | ||
{ | ||
// ReSharper disable UnusedAutoPropertyAccessor.Local | ||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Local | ||
// ReSharper disable UnusedAutoPropertyAccessor.Global | ||
public class CountryStatisticsAggregate | ||
{ | ||
public Guid Id { get; private set; } | ||
|
||
public string Country { get; private set; } | ||
|
||
public string? CountryCode { get; private set; } | ||
|
||
public int Total { get; private set; } | ||
|
||
public int New { get; private set; } | ||
|
||
public int Deaths { get; private set; } | ||
|
||
public int NewDeaths { get; private set; } | ||
|
||
public int Recovered { get; private set; } | ||
|
||
public int Active { get; private set; } | ||
public int Month { get; private set; } | ||
public int Year { get; private set; } | ||
|
||
|
||
public CountryStatisticsAggregate(string country, string? countryCode, int total, int @new, int deaths, | ||
int newDeaths, | ||
int recovered, int active, int month, int year) | ||
{ | ||
this.Country = country; | ||
this.CountryCode = countryCode; | ||
this.Total = total; | ||
this.New = @new; | ||
this.Deaths = deaths; | ||
this.NewDeaths = newDeaths; | ||
this.Recovered = recovered; | ||
this.Active = active; | ||
this.Month = month; | ||
this.Year = year; | ||
this.Id = this.Generate(); | ||
} | ||
|
||
private Guid Generate() | ||
{ | ||
using var hasher = MD5.Create(); | ||
|
||
var valueToHash = $"{nameof(CountryStatisticsAggregate)}_{this.Country}_{this.Month}_{this.Year}"; | ||
|
||
var hashed = hasher.ComputeHash(Encoding.UTF8.GetBytes(valueToHash)); | ||
|
||
return new Guid(hashed); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters