Created
August 26, 2016 14:58
-
-
Save wescleymatos/523fe88100e2a809ef868982b19f30bb to your computer and use it in GitHub Desktop.
Exemplo onde se aplica o uso de um Builder?
This file contains hidden or 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
namespace Saegrn.Domain.Services | |
{ | |
public class InscricaoService : IInscricaoService | |
{ | |
#region Properties | |
private IInscricaoRepository _inscricaoRepository; | |
private IUsuarioService _usuarioService; | |
private IOfertaService _ofertaService; | |
#endregion | |
#region Ctor | |
public InscricaoService(IInscricaoRepository inscricaoRepository, IUsuarioService usuarioService, IOfertaService ofertaService) | |
{ | |
this._inscricaoRepository = inscricaoRepository; | |
this._usuarioService = usuarioService; | |
this._ofertaService = ofertaService; | |
} | |
#endregion | |
#region Methods | |
public void Criar(Guid loginId, string cpf, Guid ofertaId, string justificativa, bool correlacaoAtividades) | |
{ | |
Usuario usuario = this._usuarioService.Verificar(loginId, cpf); | |
Oferta oferta = this._ofertaService.GetPorId(ofertaId); | |
if (oferta == null || usuario == null) | |
throw new InvalidOperationException(Errors.InvalidInscription); | |
AssertionConcern.AssertArgumentFalse(oferta.Cancelado, Errors.AlreadyCancelOffer); | |
DateTimeAssertionConcern.GreaterThanCurrentDate(oferta.DataFimInscricao, Errors.InvalidSeasonInscription); | |
Inscricao inscricao = new Inscricao(justificativa, oferta.Id, usuario.Id); | |
inscricao.SetDataInscricao(DateTime.Now); | |
inscricao.SetCorrelacaoAtividades(correlacaoAtividades); | |
inscricao.Validar(); | |
this._inscricaoRepository.Create(inscricao); | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment