public bool ExcluirTipoDePagamento(TipoDePagamento tipodepagamento) { bool ret = true; if (tipodepagamento == null) { return(false); } if (tipodepagamento.TipoDePagamentoId == Guid.Empty) { return(false); } try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoDePagamento> tipodepagamentoRepository = new Repository <TipoDePagamento>(context, unitOfWork); ITipoDePagamentoService tipodepagamentoService = new TipoDePagamentoService(tipodepagamentoRepository); tipodepagamento.ObjectState = INFRAESTRUTURA.TRANSVERSAL.Core.States.ObjectState.Deleted; tipodepagamentoService.Delete(tipodepagamento.TipoDePagamentoId); unitOfWork.SaveChanges(); (new Execute()).Sistema.Versao.NovaVersaoParaExclusao(tipodepagamento); } } catch { ret = false; } return(ret); }
public TipoDePagamento CriarNovoTipoDePagamento(TipoDePagamento tipodepagamento, bool Atualizar = false) { if (tipodepagamento == null) { tipodepagamento = new TipoDePagamento(); tipodepagamento.TipoDePagamentoId = Guid.Empty; } using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoDePagamento> tipodepagamentoRepository = new Repository <TipoDePagamento>(context, unitOfWork); ITipoDePagamentoService tipodepagamentoService = new TipoDePagamentoService(tipodepagamentoRepository); if (!ExisteTipoDePagamento(tipodepagamento.TipoDePagamentoId)) { tipodepagamento = tipodepagamentoService.NovoTipoDePagamento(tipodepagamento); unitOfWork.SaveChanges(); } else if (Atualizar) { tipodepagamento = AtualizarTipoDePagamento(tipodepagamento); unitOfWork.SaveChanges(); } unitOfWork.Dispose(); (new Execute()).Sistema.Versao.NovaVersaoParaCriacao(tipodepagamento); } return(tipodepagamento); }
public TipoDePagamento AtualizarTipoDePagamento(TipoDePagamento tipodepagamento) { if (tipodepagamento == null) { return(tipodepagamento); } using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoDePagamento> tipodepagamentoRepository = new Repository <TipoDePagamento>(context, unitOfWork); ITipoDePagamentoService tipodepagamentoService = new TipoDePagamentoService(tipodepagamentoRepository); tipodepagamento.ObjectState = INFRAESTRUTURA.TRANSVERSAL.Core.States.ObjectState.Modified; tipodepagamentoService.Update(tipodepagamento); unitOfWork.SaveChanges(); (new Execute()).Sistema.Versao.NovaVersaoParaCriacao(tipodepagamento); } return(tipodepagamento); }
public List <TipoDePagamento> BuscarTiposDePagamento(string filtro) { List <TipoDePagamento> ret = null; try { ret = new List <TipoDePagamento>(); using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoDePagamento> tipodepagamentoRepository = new Repository <TipoDePagamento>(context, unitOfWork); ITipoDePagamentoService tipodepagamentoService = new TipoDePagamentoService(tipodepagamentoRepository); ret = tipodepagamentoService.BuscarTiposDePagamento(filtro).ToList <TipoDePagamento>(); unitOfWork.Dispose(); } } catch { ret = null; } return(ret); }
public TipoDePagamento CarregarTipoDePagamento(Guid TipoDePagamentoId) { TipoDePagamento ret = null; try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoDePagamento> tipodepagamentoRepository = new Repository <TipoDePagamento>(context, unitOfWork); ITipoDePagamentoService tipodepagamentoService = new TipoDePagamentoService(tipodepagamentoRepository); ret = tipodepagamentoService.Find(TipoDePagamentoId); unitOfWork.Dispose(); } } catch { ret = null; } return(ret); }
public bool ExisteTipoDePagamento(Guid TipoDePagamentoId) { bool ret = false; try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoDePagamento> tipodepagamentoRepository = new Repository <TipoDePagamento>(context, unitOfWork); ITipoDePagamentoService tipodepagamentoService = new TipoDePagamentoService(tipodepagamentoRepository); ret = (!(tipodepagamentoService.Find(TipoDePagamentoId) == null)); unitOfWork.Dispose(); } } catch { ret = false; } return(ret); }