Skip to content

Commit 35d28fe

Browse files
feat: architecture configurations
1 parent 55cdae7 commit 35d28fe

15 files changed

Lines changed: 141 additions & 50 deletions

File tree

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
4-
<AssemblyName>CanBeYours.Application</AssemblyName>
5-
<RootNamespace>CanBeYours.Application</RootNamespace>
6-
</PropertyGroup>
7-
<ItemGroup>
8-
<PackageReference Include="CodeBlock.DevKit.Application" Version="1.3.4" />
9-
</ItemGroup>
10-
<ItemGroup>
11-
<ProjectReference Include="..\Core\Core.csproj" />
12-
</ItemGroup>
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<AssemblyName>CanBeYours.Application</AssemblyName>
5+
<RootNamespace>CanBeYours.Application</RootNamespace>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="CodeBlock.DevKit.Application" Version="1.3.4" />
9+
<PackageReference Include="CodeBlock.DevKit.Contracts" Version="1.3.4" />
10+
</ItemGroup>
11+
<ItemGroup>
12+
<ProjectReference Include="..\Core\Core.csproj" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<Folder Include="UseCases\" />
16+
</ItemGroup>
1317
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using CodeBlock.DevKit.Contracts.Dtos;
2+
3+
namespace CanBeYours.Application.Dtos;
4+
5+
public class GetDemoThingDto : GetEntityDto
6+
{
7+
public GetDemoThingDto() { }
8+
9+
public string Name { get; set; }
10+
public string Description { get; set; }
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace CanBeYours.Application.Services.DemoThings;
2+
3+
public class DemoThingService : IDemoThingService { }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace CanBeYours.Application.Services.DemoThings;
2+
3+
public interface IDemoThingService { }

src/1-Libraries/Infrastructure/DbContext/SettingsDbContext.cs renamed to src/1-Libraries/Infrastructure/DbContext/MainDbContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace CanBeYours.Infrastructure.DbContext;
66

7-
internal class DemoThingsDbContext : MongoDbContext
7+
internal class MainDbContext : MongoDbContext
88
{
9-
public DemoThingsDbContext(MongoDbSettings mongoDbSettings)
9+
public MainDbContext(MongoDbSettings mongoDbSettings)
1010
: base(mongoDbSettings) { }
1111

1212
public IMongoCollection<DemoThing> DemoThings { get; private set; }

src/1-Libraries/Infrastructure/DbContext/SettingsDbMigrator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal static class DemoThingsDbMigrator
99
public static void MigrateDatabes(this IServiceProvider serviceProvider)
1010
{
1111
using var serviceScope = serviceProvider.CreateScope();
12-
var dbContext = serviceScope.ServiceProvider.GetService<DemoThingsDbContext>();
12+
var dbContext = serviceScope.ServiceProvider.GetService<MainDbContext>();
1313
var dbMigrationRunner = serviceScope.ServiceProvider.GetService<IDbMigrationRunner>();
1414

1515
var migrations = new List<IDbMigration>

src/1-Libraries/Infrastructure/DbContext/SettingsDbSeeder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ internal static class DemoThingsDbSeeder
99
public static void SeedSampleDemoThings(this IServiceProvider serviceProvider)
1010
{
1111
using var serviceScope = serviceProvider.CreateScope();
12-
var dbContext = serviceScope.ServiceProvider.GetService<DemoThingsDbContext>();
12+
var dbContext = serviceScope.ServiceProvider.GetService<MainDbContext>();
1313

1414
serviceScope.SeedDemoThings(dbContext);
1515
}
1616

17-
private static void SeedDemoThings(this IServiceScope serviceScope, DemoThingsDbContext dbContext)
17+
private static void SeedDemoThings(this IServiceScope serviceScope, MainDbContext dbContext)
1818
{
1919
if (dbContext.DemoThings.Find(_ => true).Any())
2020
return;

src/1-Libraries/Infrastructure/DbMigrations/RenameSummaryToDescription.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ namespace CanBeYours.Infrastructure.DbMigrations;
1111

1212
internal class RenameSummaryToDescription : IDbMigration
1313
{
14-
private readonly DemoThingsDbContext _dbContext;
14+
private readonly MainDbContext _dbContext;
1515

16-
public RenameSummaryToDescription(DemoThingsDbContext dbContext)
16+
public RenameSummaryToDescription(MainDbContext dbContext)
1717
{
1818
_dbContext = dbContext;
1919
}
@@ -24,7 +24,7 @@ public RenameSummaryToDescription(DemoThingsDbContext dbContext)
2424

2525
public void Up()
2626
{
27-
var settings = _dbContext.GetCollection(nameof(DemoThingsDbContext.DemoThings));
27+
var settings = _dbContext.GetCollection(nameof(MainDbContext.DemoThings));
2828
var filter = Builders<BsonDocument>.Filter.Exists("Summary");
2929

3030
var update = Builders<BsonDocument>.Update.Rename("Summary", nameof(DemoThing.Description));
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using AutoMapper;
2+
using CanBeYours.Application.Dtos;
3+
using CanBeYours.Core.Domain.DemoThings;
4+
5+
namespace CanBeYours.Infrastructure.Mapping;
6+
7+
internal class DemoThingMappingProfile : Profile
8+
{
9+
public DemoThingMappingProfile()
10+
{
11+
CreateMap<DemoThing, GetDemoThingDto>();
12+
}
13+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) CodeBlock.Dev. All rights reserved.
2+
// For more information visit https://codeblock.dev
3+
4+
using CanBeYours.Core.Domain.DemoThings;
5+
using CanBeYours.Infrastructure.DbContext;
6+
using CodeBlock.DevKit.Infrastructure.Database;
7+
using MongoDB.Driver;
8+
9+
namespace CanBeYours.Infrastructure.Repositories;
10+
11+
internal class DemoThingRepository : MongoDbBaseAggregateRepository<DemoThing>, IDemoThingRepository
12+
{
13+
private readonly IMongoCollection<DemoThing> _demoThings;
14+
15+
public DemoThingRepository(MainDbContext dbContext)
16+
: base(dbContext.DemoThings)
17+
{
18+
_demoThings = dbContext.DemoThings;
19+
}
20+
21+
public Task<long> CountAsync(string term) => throw new NotImplementedException();
22+
23+
public Task<IEnumerable<DemoThing>> SearchAsync(string term, int pageNumber, int recordsPerPage) => throw new NotImplementedException();
24+
}

0 commit comments

Comments
 (0)