Skip to content

Commit

Permalink
Create Layers, Add Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
engindemirog committed Aug 15, 2022
1 parent cdb3c86 commit ae3b564
Show file tree
Hide file tree
Showing 18 changed files with 512 additions and 5 deletions.
48 changes: 43 additions & 5 deletions nArchitecture.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,27 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Security", "src\corePa
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templateProject", "templateProject", "{11C509DD-21AC-415F-B2F2-EB58985F2703}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application", "src\demoProjects\templateProject\Application\Application.csproj", "{78EA22FC-B933-4349-A097-556A076009F1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application", "src\demoProjects\templateProject\Application\Application.csproj", "{78EA22FC-B933-4349-A097-556A076009F1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "src\demoProjects\templateProject\Domain\Domain.csproj", "{D0D4D281-24C1-4EE0-88D6-01FA18B90442}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "src\demoProjects\templateProject\Domain\Domain.csproj", "{D0D4D281-24C1-4EE0-88D6-01FA18B90442}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "src\demoProjects\templateProject\Infrastructure\Infrastructure.csproj", "{1A88B2CE-A954-4709-B15E-F6F1210AD2FD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "src\demoProjects\templateProject\Infrastructure\Infrastructure.csproj", "{1A88B2CE-A954-4709-B15E-F6F1210AD2FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Persistence", "src\demoProjects\templateProject\Persistence\Persistence.csproj", "{53D6E924-1C32-4039-8192-CE1BEA129C61}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "src\demoProjects\templateProject\Persistence\Persistence.csproj", "{53D6E924-1C32-4039-8192-CE1BEA129C61}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "src\demoProjects\templateProject\WebAPI\WebAPI.csproj", "{54568B1F-31E7-4BA3-A2ED-826E85050603}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAPI", "src\demoProjects\templateProject\WebAPI\WebAPI.csproj", "{54568B1F-31E7-4BA3-A2ED-826E85050603}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "rentACar", "rentACar", "{E3BE1496-27FA-4B1B-B8B2-A9DC8DDDC4C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application", "src\demoProjects\rentACar\Application\Application.csproj", "{340C0C7F-5E5C-4097-9C25-B5964BBDC2D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "src\demoProjects\rentACar\Domain\Domain.csproj", "{BB849BC7-4B6B-4D55-BB2D-C90CD3D2FFD5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "src\demoProjects\rentACar\Infrastructure\Infrastructure.csproj", "{EAC94DA5-0929-42B9-95BE-1753255ACE83}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Persistence", "src\demoProjects\rentACar\Persistence\Persistence.csproj", "{5A128E9B-B7D9-43F5-8E22-2E998D70252E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "src\demoProjects\rentACar\WebAPI\WebAPI.csproj", "{B3A9582B-1FEA-4055-984E-829D05248B11}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -85,6 +97,26 @@ Global
{54568B1F-31E7-4BA3-A2ED-826E85050603}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54568B1F-31E7-4BA3-A2ED-826E85050603}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54568B1F-31E7-4BA3-A2ED-826E85050603}.Release|Any CPU.Build.0 = Release|Any CPU
{340C0C7F-5E5C-4097-9C25-B5964BBDC2D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{340C0C7F-5E5C-4097-9C25-B5964BBDC2D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{340C0C7F-5E5C-4097-9C25-B5964BBDC2D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{340C0C7F-5E5C-4097-9C25-B5964BBDC2D6}.Release|Any CPU.Build.0 = Release|Any CPU
{BB849BC7-4B6B-4D55-BB2D-C90CD3D2FFD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB849BC7-4B6B-4D55-BB2D-C90CD3D2FFD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB849BC7-4B6B-4D55-BB2D-C90CD3D2FFD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB849BC7-4B6B-4D55-BB2D-C90CD3D2FFD5}.Release|Any CPU.Build.0 = Release|Any CPU
{EAC94DA5-0929-42B9-95BE-1753255ACE83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAC94DA5-0929-42B9-95BE-1753255ACE83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAC94DA5-0929-42B9-95BE-1753255ACE83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAC94DA5-0929-42B9-95BE-1753255ACE83}.Release|Any CPU.Build.0 = Release|Any CPU
{5A128E9B-B7D9-43F5-8E22-2E998D70252E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A128E9B-B7D9-43F5-8E22-2E998D70252E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A128E9B-B7D9-43F5-8E22-2E998D70252E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A128E9B-B7D9-43F5-8E22-2E998D70252E}.Release|Any CPU.Build.0 = Release|Any CPU
{B3A9582B-1FEA-4055-984E-829D05248B11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3A9582B-1FEA-4055-984E-829D05248B11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3A9582B-1FEA-4055-984E-829D05248B11}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3A9582B-1FEA-4055-984E-829D05248B11}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -104,6 +136,12 @@ Global
{1A88B2CE-A954-4709-B15E-F6F1210AD2FD} = {11C509DD-21AC-415F-B2F2-EB58985F2703}
{53D6E924-1C32-4039-8192-CE1BEA129C61} = {11C509DD-21AC-415F-B2F2-EB58985F2703}
{54568B1F-31E7-4BA3-A2ED-826E85050603} = {11C509DD-21AC-415F-B2F2-EB58985F2703}
{E3BE1496-27FA-4B1B-B8B2-A9DC8DDDC4C3} = {84E05683-0E4A-4FB1-8FD4-9F0C509BC74C}
{340C0C7F-5E5C-4097-9C25-B5964BBDC2D6} = {E3BE1496-27FA-4B1B-B8B2-A9DC8DDDC4C3}
{BB849BC7-4B6B-4D55-BB2D-C90CD3D2FFD5} = {E3BE1496-27FA-4B1B-B8B2-A9DC8DDDC4C3}
{EAC94DA5-0929-42B9-95BE-1753255ACE83} = {E3BE1496-27FA-4B1B-B8B2-A9DC8DDDC4C3}
{5A128E9B-B7D9-43F5-8E22-2E998D70252E} = {E3BE1496-27FA-4B1B-B8B2-A9DC8DDDC4C3}
{B3A9582B-1FEA-4055-984E-829D05248B11} = {E3BE1496-27FA-4B1B-B8B2-A9DC8DDDC4C3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C127633B-AB1B-43AE-A516-DCF06F13F757}
Expand Down
17 changes: 17 additions & 0 deletions src/demoProjects/rentACar/Application/Application.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Folder Include="Features\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Core.Persistence.Repositories;
using Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Services.Repositories
{
public interface IBrandRepository: IAsyncRepository<Brand>, IRepository<Brand>
{

}
}
17 changes: 17 additions & 0 deletions src/demoProjects/rentACar/Domain/Domain.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\corePackages\Core.Persistence\Core.Persistence.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Enums\" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions src/demoProjects/rentACar/Domain/Entities/Brand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Core.Persistence.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain.Entities
{
public class Brand:Entity
{
public string Name { get; set; }

public Brand()
{
}

public Brand(int id, string name):this()
{
Id = id;
Name = name;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
47 changes: 47 additions & 0 deletions src/demoProjects/rentACar/Persistence/Contexts/BaseDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Persistence.Contexts
{
public class BaseDbContext : DbContext
{
protected IConfiguration Configuration { get; set; }
public DbSet<Brand> Brands { get; set; }


public BaseDbContext(DbContextOptions dbContextOptions, IConfiguration configuration) : base(dbContextOptions)
{
Configuration = configuration;
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
//if (!optionsBuilder.IsConfigured)
// base.OnConfiguring(
// optionsBuilder.UseSqlServer(Configuration.GetConnectionString("SomeConnectionString")));
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Brand>(a =>
{
a.ToTable("Brands").HasKey(k => k.Id);
a.Property(p => p.Id).HasColumnName("Id");
a.Property(p => p.Name).HasColumnName("Name");
});



Brand[] brandEntitySeeds = { new(1, "BMW"), new(2, "Mercedes") };
modelBuilder.Entity<Brand>().HasData(brandEntitySeeds);


}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Persistence.Migrations
{
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Brands",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Brands", x => x.Id);
});

migrationBuilder.InsertData(
table: "Brands",
columns: new[] { "Id", "Name" },
values: new object[] { 1, "BMW" });

migrationBuilder.InsertData(
table: "Brands",
columns: new[] { "Id", "Name" },
values: new object[] { 2, "Mercedes" });
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Brands");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Persistence.Contexts;

#nullable disable

namespace Persistence.Migrations
{
[DbContext(typeof(BaseDbContext))]
partial class BaseDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);

modelBuilder.Entity("Domain.Entities.Brand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("Id");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasColumnName("Name");

b.HasKey("Id");

b.ToTable("Brands", (string)null);

b.HasData(
new
{
Id = 1,
Name = "BMW"
},
new
{
Id = 2,
Name = "Mercedes"
});
});
#pragma warning restore 612, 618
}
}
}
20 changes: 20 additions & 0 deletions src/demoProjects/rentACar/Persistence/Persistence.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit ae3b564

Please sign in to comment.