-
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.
Merge pull request #10 from LibardiFelipe/teste
Teste
- Loading branch information
Showing
55 changed files
with
1,223 additions
and
173 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
14 changes: 14 additions & 0 deletions
14
TemplateBase.Application/Commands/TemplatesEmail/CreateEmailTemplateCommand.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 TemplateBase.Application.Commands.Base; | ||
|
||
namespace TemplateBase.Application.Commands.TemplatesEmail | ||
{ | ||
public class CreateTemplateEmailCommand : Command | ||
{ | ||
public string Name { get; set; } | ||
public string Body { get; set; } | ||
|
||
public override void Validate() | ||
{ | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
TemplateBase.Application/Commands/TemplatesEmail/DeleteEmailTemplateCommand.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,19 @@ | ||
using System; | ||
using TemplateBase.Application.Commands.Base; | ||
|
||
namespace TemplateBase.Application.Commands.TemplatesEmail | ||
{ | ||
public class DeleteEmailTemplateCommand : Command | ||
{ | ||
public DeleteEmailTemplateCommand(Guid id) | ||
{ | ||
Id = id; | ||
} | ||
|
||
public Guid Id { get; set; } | ||
|
||
public override void Validate() | ||
{ | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
TemplateBase.Application/Commands/TemplatesEmail/EmailTemplateCommandHandler.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,62 @@ | ||
using MediatR; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using TemplateBase.Application.Commands.Base; | ||
using TemplateBase.Application.Models; | ||
using TemplateBase.Domain.Resources; | ||
using TemplateBase.Domain.Services.Contracts; | ||
|
||
namespace TemplateBase.Application.Commands.TemplatesEmail | ||
{ | ||
public class TemplateEmailCommandHandler : CommandHandler, | ||
IRequestHandler<CreateTemplateEmailCommand, Result>, | ||
IRequestHandler<UpdateTemplateEmailCommand, Result>, | ||
IRequestHandler<DeleteEmailTemplateCommand, Result> | ||
{ | ||
private readonly ITemplateEmailService _emailTemplateService; | ||
|
||
public TemplateEmailCommandHandler(ITemplateEmailService emailTemplateService) | ||
{ | ||
_emailTemplateService = emailTemplateService; | ||
} | ||
|
||
public async Task<Result> Handle(CreateTemplateEmailCommand request, CancellationToken cancellationToken) | ||
{ | ||
if (request.IsInvalid()) | ||
return new Result(DefaultMessages.Handler_ComandoInvalido, false, request.Notifications); | ||
|
||
var entity = await _emailTemplateService.CreateTemplateEmailAsync(request.Name, request.Body, cancellationToken); | ||
|
||
if (_emailTemplateService.IsInvalid()) | ||
return new Result(DefaultMessages.Handler_FalhaAoExecutarComando, false, _emailTemplateService.GetNotifications()); | ||
|
||
return new Result(DefaultMessages.Handler_ComandoExecutado, true, entity); | ||
} | ||
|
||
public async Task<Result> Handle(UpdateTemplateEmailCommand request, CancellationToken cancellationToken) | ||
{ | ||
if (request.IsInvalid()) | ||
return new Result(DefaultMessages.Handler_ComandoInvalido, false, request.Notifications); | ||
|
||
var entity = await _emailTemplateService.UpdateTemplateEmailAsync(request.Id, request.Name, request.Body, cancellationToken); | ||
|
||
if (_emailTemplateService.IsInvalid()) | ||
return new Result(DefaultMessages.Handler_FalhaAoExecutarComando, false, _emailTemplateService.GetNotifications()); | ||
|
||
return new Result(DefaultMessages.Handler_ComandoExecutado, true, entity); | ||
} | ||
|
||
public async Task<Result> Handle(DeleteEmailTemplateCommand request, CancellationToken cancellationToken) | ||
{ | ||
if (request.IsInvalid()) | ||
return new Result(DefaultMessages.Handler_ComandoInvalido, false, request.Notifications); | ||
|
||
var entity = await _emailTemplateService.DeleteTemplateEmailAsync(request.Id, cancellationToken); | ||
|
||
if (_emailTemplateService.IsInvalid()) | ||
return new Result(DefaultMessages.Handler_FalhaAoExecutarComando, false, _emailTemplateService.GetNotifications()); | ||
|
||
return new Result(DefaultMessages.Handler_ComandoExecutado, true, entity); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
TemplateBase.Application/Commands/TemplatesEmail/UpdateTemplateEmailCommand.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,16 @@ | ||
using System; | ||
using TemplateBase.Application.Commands.Base; | ||
|
||
namespace TemplateBase.Application.Commands.TemplatesEmail | ||
{ | ||
public class UpdateTemplateEmailCommand : Command | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public string Body { get; set; } | ||
|
||
public override void Validate() | ||
{ | ||
} | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
...ation/Commands/Users/CreateUserCommand.cs → ...ion/Commands/Users/RegisterUserCommand.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
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
23 changes: 23 additions & 0 deletions
23
TemplateBase.Application/Commands/Users/VerifyUserCommand.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,23 @@ | ||
using TemplateBase.Application.Commands.Base; | ||
|
||
namespace TemplateBase.Application.Commands.Auth | ||
{ | ||
public class VerifyUserCommand : Command | ||
{ | ||
public VerifyUserCommand() | ||
{ | ||
|
||
} | ||
|
||
public VerifyUserCommand(string hash) | ||
{ | ||
Hash = hash; | ||
} | ||
|
||
public string Hash { get; set; } | ||
|
||
public override void Validate() | ||
{ | ||
} | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
TemplateBase.Application/Queries/TemplatesEmail/TemplateEmailQuery.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,38 @@ | ||
using TemplateBase.Application.Queries.Base; | ||
using TemplateBase.Domain.Contracts; | ||
using TemplateBase.Domain.Entities; | ||
using TemplateBase.Domain.Specifications; | ||
|
||
namespace TemplateBase.Application.Queries.TemplatesEmail | ||
{ | ||
public class TemplateEmailQuery : Query<TemplateEmail> | ||
{ | ||
#region Construtores | ||
public TemplateEmailQuery() { } | ||
public TemplateEmailQuery(string id) : base(id) { } | ||
#endregion | ||
|
||
#region Specification | ||
public override ISpecification<TemplateEmail> ToSpecification() | ||
{ | ||
var spec = new TemplateEmailSpec(); | ||
|
||
if (_id.HasValue) | ||
spec.FilterById(_id.Value); | ||
|
||
return spec; | ||
} | ||
#endregion | ||
|
||
#region Validações | ||
public override void Validate() | ||
{ | ||
/* | ||
* Caso queira trabalhar com failfast validations, | ||
* aqui dentro é o local onde essas validações | ||
* deverão ser feitas. | ||
*/ | ||
} | ||
#endregion | ||
} | ||
} |
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,33 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace TemplateBase.Domain.Classes | ||
{ | ||
public class Email | ||
{ | ||
private List<string> _addressees = new List<string>(); | ||
|
||
public string Subject { get; set; } | ||
public string Body { get; set; } | ||
public IReadOnlyCollection<string> Addressees { get { return _addressees; } } | ||
|
||
public void InjectToBody(Dictionary<string, string> values) | ||
{ | ||
if (string.IsNullOrWhiteSpace(Body)) | ||
return; | ||
|
||
foreach (var item in values) | ||
Body = Body.Replace(item.Key, item.Value); | ||
} | ||
|
||
public void AddAddressee(string email) | ||
{ | ||
_addressees.Add(email.Trim()); | ||
} | ||
|
||
public void AddAddressee(List<string> emails) | ||
{ | ||
foreach (var email in emails) | ||
_addressees.Add(email.Trim()); | ||
} | ||
} | ||
} |
Oops, something went wrong.