Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using Metavision.Infra.Data;
- namespace Metavision.Infra.Tests
- {
- public class RepositorioPessoas : Repositorio<Pessoa>
- {
- public RepositorioPessoas(IUnitOfWork unitOfWork)
- : base(unitOfWork)
- {
- }
- public override void AddEntity(Pessoa entity)
- {
- //efetuar alguma ação antes de adicionar uma entidade no repositório
- entity.Data = DateTime.Now;
- base.AddEntity(entity);
- }
- public override void RemoveEntity(Pessoa entity)
- {
- //efetuar alguma ação antes de remover uma entidade no repositório
- entity.Enderecos.Clear();
- base.RemoveEntity(entity);
- }
- public override IEnumerable<Pessoa> GetAll(Func<Pessoa, bool> specification = null)
- {
- //efetuar alguma ação antes de recuperar todos os objetos
- if (specification == null)
- specification = pessoa => pessoa.Id > 0;
- return base.GetAll(specification);
- }
- /* Alterando a Factory padrão do repositório */
- public override Func<Pessoa> Factory
- {
- get
- {
- return () => new Pessoa { Data = DateTime.Now };
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement