Created
October 22, 2014 01:38
-
-
Save jpolvora/3e67238275b6cd079403 to your computer and use it in GitHub Desktop.
teste repository pattern
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
public class EstoqueRepository : RepositoryBase<Estoque> | |
{ | |
public EstoqueRepository(CustomUnitOfWork uow) | |
: base(uow) | |
{ | |
} | |
public override bool Validate(Estoque estoque) | |
{ | |
var isValid = base.Validate(estoque); | |
if (isValid) | |
{ | |
var estoques = AsQueryable(); | |
if (estoques.Any(x => x.AutomovelId.Equals(estoque.AutomovelId) | |
&& x.RevendedoraId.Equals(estoque.RevendedoraId))) | |
{ | |
throw new BusinessException("Automóvel já vinculado a esta Revendedora. Por favor, verifique."); | |
} | |
} | |
return isValid; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment