Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }