Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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