-
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.
feat(seeding,datetimes): added context seeders; added datetimes to ex…
…penses and domain level utc normalizers as well as existing expenses specification extension
- Loading branch information
Showing
20 changed files
with
361 additions
and
378 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
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,10 @@ | ||
namespace Application.Features.Shared; | ||
|
||
public record ExpenseDTO(Guid Id, string Name, string Description, double Value, Guid CategoryId); | ||
public record ExpenseDTO( | ||
Guid Id, | ||
string Name, | ||
string Description, | ||
double Value, | ||
DateTime Date, | ||
Guid CategoryId | ||
); |
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,7 @@ | ||
namespace Domain.Conversors; | ||
|
||
public static class DateTimeConversors | ||
{ | ||
public static DateTime NormalizeToUtc(DateTime date) => | ||
date.Kind == DateTimeKind.Utc ? date : date.ToUniversalTime(); | ||
} |
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,4 +1,5 @@ | ||
global using Ardalis.Specification; | ||
global using Domain.Conversors; | ||
global using Domain.Entities; | ||
global using Microsoft.AspNetCore.Identity; | ||
global using Microsoft.EntityFrameworkCore; |
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,96 @@ | ||
namespace Infrastructure.Extensions; | ||
|
||
public static class SeedingExtension | ||
{ | ||
public static void SeedData(this ModelBuilder builder) | ||
{ | ||
var ids = new List<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }; | ||
builder | ||
.Entity<Category>() | ||
.HasData( | ||
new() | ||
{ | ||
Id = ids[0], | ||
Name = "Groceries", | ||
Description = "Groceries category.", | ||
}, | ||
new() | ||
{ | ||
Id = ids[1], | ||
Name = "Transportation", | ||
Description = "Transportation category.", | ||
}, | ||
new() | ||
{ | ||
Id = ids[2], | ||
Name = "Leisure", | ||
Description = "Leisure category.", | ||
}, | ||
new() | ||
{ | ||
Id = ids[3], | ||
Name = "Utilities", | ||
Description = "Utilities category.", | ||
} | ||
); | ||
|
||
builder | ||
.Entity<Expense>() | ||
.HasData( | ||
new() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "200g of chicken", | ||
Description = "Some chicken bought in the supermarket", | ||
Value = 2.05, | ||
Date = DateTime.UtcNow, | ||
CategoryId = ids[0], | ||
}, | ||
new() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "1 can of beans", | ||
Description = "Some chicken bought in the supermarket", | ||
Value = 2, | ||
Date = DateTime.UtcNow, | ||
CategoryId = ids[0], | ||
}, | ||
new() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "Full car tank", | ||
Description = "Full car tank of 95", | ||
Value = 50, | ||
Date = DateTime.UtcNow, | ||
CategoryId = ids[1], | ||
}, | ||
new() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "Random film", | ||
Description = "A film I watched", | ||
Value = 5.90, | ||
Date = DateTime.UtcNow, | ||
CategoryId = ids[2], | ||
}, | ||
new() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "Electricity", | ||
Description = "Electricity bill", | ||
Value = 40, | ||
Date = DateTime.UtcNow, | ||
CategoryId = ids[3], | ||
}, | ||
new() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "Water", | ||
Description = "Water bill", | ||
Value = 15, | ||
Date = DateTime.UtcNow, | ||
CategoryId = ids[3], | ||
} | ||
); | ||
} | ||
} |
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.