Skip to content

Commit

Permalink
Merge pull request #4 from rcdmk/translate-to-english
Browse files Browse the repository at this point in the history
Translate to project to english
  • Loading branch information
rcdmk authored Nov 29, 2022
2 parents d532ef9 + a100d75 commit f3e0baf
Show file tree
Hide file tree
Showing 75 changed files with 694 additions and 766 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Projeto de estrutura DDD
# DDD structure project

[![Build status](https://ci.appveyor.com/api/projects/status/799cc3qwne3d6el0?svg=true)](https://ci.appveyor.com/project/rcdmk/testepraticoddd)

Este projeto utiliza diversos padrões de desenvolvimento como modelo de aprendizado:
This project uses diverse development patterns as learning model:

* DDD - Arquitetura orientada ao domínio
* SelfValidation - As entidades possuem auto validação e são responsáveis por seu estado de validade com regras de negócio.
* Repository - A comunicação com a camada de dados é efetuada através de repositórios
* Application Services - O acesso aos dados é efetuado através de serviços WCF
* ... (mais por vir)
* DDD - Domain oriented architecture
* SelfValidation - Entities have auto-validation and are responsible for their own business rules validity state.
* Repository - The data layer communication is done through repositories
* Application Services - Data access is done through application services that can be reused by different applications (eg. Web and gRPC Services)
* AutoMapper - Mapping from entities to and from view models and DTOs is handled by AutoMapper
* IoC - Dependency injection is handled by .Net Core DI framework
* ... (more to come)
27 changes: 11 additions & 16 deletions TestePratico.Application/Interfaces/IAppServiceBase.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Linq.Expressions;
using TestePratico.Domain.Validation;

namespace TestePratico.Application.Interfaces
{
public interface IAppServiceBase<TEntity> : IDisposable where TEntity : class
{
TEntity GetById(int id);
public interface IAppServiceBase<TEntity> : IDisposable where TEntity : class
{
TEntity GetById(int id);

IEnumerable<TEntity> GetAll();
IEnumerable<TEntity> GetAll();

IEnumerable<TEntity> Find(Expression<Func<TEntity, bool>> filter);
IEnumerable<TEntity> Find(Expression<Func<TEntity, bool>> filter);

ValidationResult Add(TEntity obj);
ValidationResult Add(TEntity obj);

ValidationResult Update(TEntity obj);
ValidationResult Update(TEntity obj);

ValidationResult Remove(TEntity obj);
ValidationResult Remove(TEntity obj);

void SaveChanges();
}
void SaveChanges();
}
}
13 changes: 4 additions & 9 deletions TestePratico.Application/Interfaces/IPessoaAppService.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestePratico.Domain.Entities;
using TestePratico.Domain.Entities;

namespace TestePratico.Application.Interfaces
{
public interface IPessoaAppService : IAppServiceBase<Pessoa>
{
}
public interface IPersonAppService : IAppServiceBase<Person>
{
}
}
13 changes: 4 additions & 9 deletions TestePratico.Application/Interfaces/IUFAppService.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestePratico.Domain.Entities;
using TestePratico.Domain.Entities;

namespace TestePratico.Application.Interfaces
{
public interface IUFAppService : IAppServiceBase<UF>
{
}
public interface IUFAppService : IAppServiceBase<UF>
{
}
}
17 changes: 17 additions & 0 deletions TestePratico.Application/PersonAppService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using TestePratico.Application.Interfaces;
using TestePratico.Domain.Entities;
using TestePratico.Domain.Interfaces.Services;

namespace TestePratico.Application
{
public class PersonAppService : AppServiceBase<Person>, IPersonAppService
{
private readonly IPersonService service;

public PersonAppService(IPersonService service)
: base(service)
{
this.service = service;
}
}
}
17 changes: 0 additions & 17 deletions TestePratico.Application/PessoaAppService.cs

This file was deleted.

6 changes: 3 additions & 3 deletions TestePratico.Data/Context/TestePraticoContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace TestePratico.Data.Context
{
public class TestePraticoContext : DbContext
{
public DbSet<Pessoa> Pessoas { get; set; } = null!;
public DbSet<UF> UF { get; set; } = null!;
public DbSet<Person> People { get; set; } = null!;
public DbSet<UF> UFs { get; set; } = null!;

protected TestePraticoContext()
{
Expand All @@ -25,7 +25,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new PessoaConfiguration());
modelBuilder.ApplyConfiguration(new PersonConfiguration());
modelBuilder.ApplyConfiguration(new UFConfiguration());
}

Expand Down
5 changes: 0 additions & 5 deletions TestePratico.Data/EntityConfig/EntityBaseConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TestePratico.Domain.Entities;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TestePratico.Domain.Entities;

namespace TestePratico.Data.EntityConfig
{
public class PessoaConfiguration : EntityBaseConfiguration<Pessoa>
public class PersonConfiguration : EntityBaseConfiguration<Person>
{
public PessoaConfiguration()
public PersonConfiguration()
{

}

public override void Configure(EntityTypeBuilder<Pessoa> builder)
public override void Configure(EntityTypeBuilder<Person> builder)
{
base.Configure(builder);

builder.Property(p => p.Nome)
builder.ToTable("People");

builder.Property(p => p.Name)
.IsRequired()
.HasMaxLength(150);

builder.Property(p => p.DDD)
builder.Property(p => p.AreaCode)
.HasMaxLength(2);

builder.Property(p => p.Telefone)
builder.Property(p => p.Phone)
.HasMaxLength(10);

builder.Property(p => p.Email)
Expand Down
4 changes: 2 additions & 2 deletions TestePratico.Data/EntityConfig/UFConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public override void Configure(EntityTypeBuilder<UF> builder)

builder.ToTable("UFs");

builder.Property(u => u.Nome)
builder.Property(u => u.Name)
.IsRequired()
.HasMaxLength(50);

builder.Ignore(u => u.ValidationResult);
builder.Ignore(u => u.IsValid);

builder.HasData(new[]{
new UF(UFId: 1, nome: "SP")
new UF(UFId: 1, name: "SP")
});
}
}
Expand Down

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

29 changes: 14 additions & 15 deletions TestePratico.Data/Migrations/20221028183827_Initial setup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable
Expand All @@ -19,7 +18,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
UFId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Nome = table.Column<string>(type: "varchar(50)", unicode: false, maxLength: 50, nullable: false)
Name = table.Column<string>(type: "varchar(50)", unicode: false, maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
Expand All @@ -29,27 +28,27 @@ protected override void Up(MigrationBuilder migrationBuilder)
.Annotation("MySql:CharSet", "utf8mb4");

migrationBuilder.CreateTable(
name: "Pessoas",
name: "People",
columns: table => new
{
PessoaId = table.Column<int>(type: "int", nullable: false)
PersonId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Nome = table.Column<string>(type: "varchar(150)", unicode: false, maxLength: 150, nullable: false)
Name = table.Column<string>(type: "varchar(150)", unicode: false, maxLength: 150, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DataNascimento = table.Column<DateOnly>(type: "date", nullable: true),
DDD = table.Column<string>(type: "varchar(2)", unicode: false, maxLength: 2, nullable: false)
Birthdate = table.Column<DateOnly>(type: "date", nullable: true),
AreaCode = table.Column<string>(type: "varchar(2)", unicode: false, maxLength: 2, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Telefone = table.Column<string>(type: "varchar(10)", unicode: false, maxLength: 10, nullable: false)
Phone = table.Column<string>(type: "varchar(10)", unicode: false, maxLength: 10, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "varchar(150)", unicode: false, maxLength: 150, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
UFId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Pessoas", x => x.PessoaId);
table.PrimaryKey("PK_People", x => x.PersonId);
table.ForeignKey(
name: "FK_Pessoas_UFs_UFId",
name: "FK_People_UFs_UFId",
column: x => x.UFId,
principalTable: "UFs",
principalColumn: "UFId");
Expand All @@ -58,19 +57,19 @@ protected override void Up(MigrationBuilder migrationBuilder)

migrationBuilder.InsertData(
table: "UFs",
columns: new[] { "UFId", "Nome" },
columns: new[] { "UFId", "Name" },
values: new object[] { 1, "SP" });

migrationBuilder.CreateIndex(
name: "IX_Pessoas_UFId",
table: "Pessoas",
name: "IX_People_UFId",
table: "People",
column: "UFId");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Pessoas");
name: "People");

migrationBuilder.DropTable(
name: "UFs");
Expand Down
Loading

0 comments on commit f3e0baf

Please sign in to comment.