-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
232 trekkspill m backend stotte (#248)
Co-authored-by: Sigrid Elnan <sge@variant.no>
- Loading branch information
1 parent
4d062eb
commit 3d75a81
Showing
10 changed files
with
407 additions
and
188 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
namespace Core.DomainModels; | ||
|
||
public record Week(int Year, int WeekNumber); | ||
public class Week : IComparable<Week>, IEquatable<Week> | ||
|
||
{ | ||
public Week(int year, int weekNumber) | ||
{ | ||
Year = year; | ||
WeekNumber = weekNumber; | ||
} | ||
|
||
public int Year { get; set; } | ||
public int WeekNumber { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return ($"{Year}{WeekNumber}"); | ||
} | ||
|
||
|
||
public int CompareTo(Week? other) | ||
{ | ||
// 1 if this is first | ||
// 0 if equal | ||
if (other is null) | ||
return 1; | ||
|
||
if (Year == other.Year) return WeekNumber - other.WeekNumber; | ||
|
||
return Year - other.Year; | ||
} | ||
|
||
public bool Equals(Week? other) | ||
{ | ||
if (other is null) return false; | ||
return Year == other.Year && WeekNumber == other.WeekNumber; | ||
} | ||
} |
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
Oops, something went wrong.