-
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.
* Fix a typo * Add interfaces for dates * Enhance `BaseCrudService` Now `BaseCrudService` can assign creation and/or update dates to entities which have implemented `IHasCreationDate` and/or `IHasUpdateDate` interfaces. * Add creation and update dates to 5 entities Entities affected: * Grade * Classroom * Course * Group * Semester * Update view DTOs * Update tests * Update fake data generation
- Loading branch information
1 parent
179335f
commit 612a7e4
Showing
28 changed files
with
1,124 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
namespace EUniversity.Core.Dtos.University; | ||
|
||
public record ClassroomViewDto(int Id, string Name); | ||
public record ClassroomViewDto(int Id, string Name, | ||
DateTimeOffset CreationDate, DateTimeOffset UpdateDate); |
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,5 @@ | ||
namespace EUniversity.Core.Dtos.University; | ||
|
||
public record CoursePreviewDto(int Id, string Name, SemesterMinimalViewDto? Semester); | ||
public record CoursePreviewDto(int Id, string Name, | ||
DateTimeOffset CreationDate, DateTimeOffset UpdateDate, | ||
SemesterMinimalViewDto? Semester); |
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,5 @@ | ||
namespace EUniversity.Core.Dtos.University; | ||
|
||
public record CourseViewDto(int Id, string Name, string? Description, SemesterPreviewDto? Semester); | ||
public record CourseViewDto(int Id, string Name, string? Description, | ||
DateTimeOffset CreationDate, DateTimeOffset UpdateDate, | ||
SemesterPreviewDto? Semester); |
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,4 @@ | ||
namespace EUniversity.Core.Dtos.University.Grades; | ||
|
||
public record GradeViewDto(int Id, string Name, int Score); | ||
public record GradeViewDto(int Id, string Name, int Score, | ||
DateTimeOffset CreationDate, DateTimeOffset UpdateDate); |
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,5 @@ | ||
namespace EUniversity.Core.Dtos.University; | ||
|
||
public record SemesterPreviewDto(int Id, string Name, DateTimeOffset DateFrom, DateTimeOffset DateTo); | ||
public record SemesterPreviewDto(int Id, string Name, | ||
DateTimeOffset CreationDate, DateTimeOffset UpdateDate, | ||
DateTimeOffset DateFrom, DateTimeOffset DateTo); |
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,5 +1,6 @@ | ||
namespace EUniversity.Core.Dtos.University; | ||
|
||
public record SemesterViewDto(int Id, string Name, | ||
DateTimeOffset CreationDate, DateTimeOffset UpdateDate, | ||
DateTimeOffset DateFrom, DateTimeOffset DateTo, | ||
IEnumerable<StudentSemesterViewDto> StudentEnrollments); |
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,12 @@ | ||
namespace EUniversity.Core.Models; | ||
|
||
/// <summary> | ||
/// An interface that defines an entity that has a creation date property. | ||
/// </summary> | ||
public interface IHasCreationDate | ||
{ | ||
/// <summary> | ||
/// Date when the entity was created. | ||
/// </summary> | ||
public DateTimeOffset CreationDate { get; set; } | ||
} |
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,12 @@ | ||
namespace EUniversity.Core.Models; | ||
|
||
/// <summary> | ||
/// An interface that defines an entity that has an update(edit) date property. | ||
/// </summary> | ||
public interface IHasUpdateDate | ||
{ | ||
/// <summary> | ||
/// Date when the entity was last updated. | ||
/// </summary> | ||
public DateTimeOffset UpdateDate { get; set; } | ||
} |
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
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,16 @@ | ||
using Bogus; | ||
using EUniversity.Core.Models; | ||
|
||
namespace EUniversity.Infrastructure.Extensions; | ||
|
||
public static class FakerExtensions | ||
{ | ||
public static Faker<T> RuleForDates<T>(this Faker<T> faker) | ||
where T : class, IHasCreationDate, IHasUpdateDate | ||
{ | ||
return faker | ||
.RuleFor(x => x.CreationDate, f => f.Date.RecentOffset(180)) | ||
.RuleFor(x => x.UpdateDate, | ||
(f, x) => f.Date.BetweenOffset(x.CreationDate, x.CreationDate + TimeSpan.FromDays(90))); | ||
} | ||
} |
Oops, something went wrong.