Skip to content

Instantly share code, notes, and snippets.

@jpolvora
Created October 22, 2014 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpolvora/3e67238275b6cd079403 to your computer and use it in GitHub Desktop.
Save jpolvora/3e67238275b6cd079403 to your computer and use it in GitHub Desktop.
teste repository pattern
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