-
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.
Feature: Entidade de template para emails adicionada.
- Loading branch information
1 parent
7455db5
commit 4c8ef1f
Showing
6 changed files
with
211 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Flunt.Notifications; | ||
using Flunt.Validations; | ||
using TemplateBase.Domain.Entities.Base; | ||
using TemplateBase.Domain.Resources; | ||
|
||
namespace TemplateBase.Domain.Entities | ||
{ | ||
public class TemplateEmail : Entity | ||
{ | ||
public TemplateEmail() { } | ||
public TemplateEmail(string name, string body) | ||
{ | ||
ChangeName(name, true); | ||
ChangeBody(body, true); | ||
} | ||
|
||
public string Name { get; private set; } | ||
public string Body { get; private set; } | ||
|
||
public TemplateEmail ChangeName(string value, bool fromConstructor = false) | ||
{ | ||
if (!fromConstructor && (Name?.Equals(value) ?? false)) | ||
return this; | ||
|
||
Name = value; | ||
AddNotifications(new Contract<Notification>() | ||
.Requires() | ||
.IsNotNullOrWhiteSpace(Name, "Name", string.Format(DefaultMessages.CampoObrigatorio, "Nome"))); | ||
|
||
FlagAsChanged(); | ||
return this; | ||
} | ||
|
||
public TemplateEmail ChangeBody(string value, bool fromConstructor = false) | ||
{ | ||
if (!fromConstructor && (Body?.Equals(value) ?? false)) | ||
return this; | ||
|
||
Body = value; | ||
AddNotifications(new Contract<Notification>() | ||
.Requires() | ||
.IsNotNullOrWhiteSpace(Body, "Body", string.Format(DefaultMessages.CampoObrigatorio, "Corpo"))); | ||
|
||
FlagAsChanged(); | ||
return this; | ||
} | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
TemplateBase.Infrastructure/Migrations/20221009002248_TemplateEmailAdded.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
TemplateBase.Infrastructure/Migrations/20221009002248_TemplateEmailAdded.cs
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,34 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace TemplateBase.Infrastructure.Migrations | ||
{ | ||
public partial class TemplateEmailAdded : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "TemplateEmail", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(type: "TEXT", nullable: false), | ||
Name = table.Column<string>(type: "TEXT", nullable: true), | ||
Body = table.Column<string>(type: "TEXT", nullable: true), | ||
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false), | ||
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_TemplateEmail", x => x.Id); | ||
}); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "TemplateEmail"); | ||
} | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
TemplateBase.Infrastructure/Persistence/Contexts/DataConfig/TemplateEmailConfig.cs
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,14 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using TemplateBase.Domain.Entities; | ||
|
||
namespace TemplateBase.Infrastructure.Persistence.Contexts.DataConfig | ||
{ | ||
internal class TemplateEmailConfig : EntityConfig<TemplateEmail> | ||
{ | ||
public override void Configure(EntityTypeBuilder<TemplateEmail> builder) | ||
{ | ||
builder.ToTable("TemplateEmail"); | ||
} | ||
} | ||
} |
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