Exemple #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);
        }
Exemple #2
0
        public static bool ExcluirTipoDePagamento(this IRepository <TipoDePagamento> repository, Guid TipoDePagamentoId)
        {
            bool ret = true;

            try
            {
                TipoDePagamento tipodepagamento = null;

                var query = from item in repository.Queryable()
                            where item.TipoDePagamentoId == TipoDePagamentoId
                            select item;

                tipodepagamento = query.SingleOrDefault <TipoDePagamento>();

                if (tipodepagamento != null)
                {
                    throw new Exception("O Tipo de Pagamento não pode ser excluido, pois o mesmo não foi encontrado na base de dados.");
                }

                repository.Delete(tipodepagamento);
            }
            catch
            {
                ret = false;
            }
            return(ret);
        }
Exemple #3
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);
        }
Exemple #4
0
        public static TipoDePagamentoView EditarTipoDePagamento(TipoDePagamentoView tipodepagamento, string AlteradoPor, DateTime AlteradoEm)
        {
            TipoDePagamento objdomin = tipodepagamento.DeViewParaDomin();

            objdomin.AlteradoPor = AlteradoPor;
            objdomin.AlteradoEm  = AlteradoEm;

            tipodepagamento = Executar.Cadastro.TipoDePagamento.AtualizarTipoDePagamento(tipodepagamento.DeViewParaDomin()).DeDominParaView();
            return(tipodepagamento);
        }
Exemple #5
0
        public static TipoDePagamentoView CriarNovoTipoDePagamento(TipoDePagamentoView tipodepagamento, string CriadoPor, DateTime CriadoEm)
        {
            TipoDePagamento objdomain = tipodepagamento.DeViewParaDomin();

            objdomain.CriadoPor = CriadoPor;
            objdomain.CriadoEm  = CriadoEm;

            tipodepagamento = Executar.Cadastro.TipoDePagamento.CriarNovoTipoDePagamento(tipodepagamento.DeViewParaDomin()).DeDominParaView();
            return(tipodepagamento);
        }
Exemple #6
0
        public static bool ExcluirTipoDePagamento(TipoDePagamentoView tipodepagamento, string AlteradoPor, DateTime AlteradoEm)
        {
            TipoDePagamento objdomin = tipodepagamento.DeViewParaDomin();

            objdomin.AlteradoPor = AlteradoPor;
            objdomin.AlteradoEm  = AlteradoEm;

            bool ret = Executar.Cadastro.TipoDePagamento.ExcluirTipoDePagamento(tipodepagamento.DeViewParaDomin());

            return(ret);
        }
Exemple #7
0
        public static TipoDePagamentoView DeDominParaView(this TipoDePagamento source)
        {
            TipoDePagamentoView tipodepagamento = new TipoDePagamentoView()
            {
                TipoDePagamentoId = source.TipoDePagamentoId,
                Descricao         = source.Descricao,
                Ativo             = source.Ativo
            };

            return(tipodepagamento);
        }
Exemple #8
0
        public static TipoDePagamento DeViewParaDomin(this TipoDePagamentoView source)
        {
            TipoDePagamento tipodepagamento = new TipoDePagamento()
            {
                TipoDePagamentoId = source.TipoDePagamentoId,
                Descricao         = source.Descricao,
                Ativo             = source.Ativo
            };

            return(tipodepagamento);
        }
Exemple #9
0
 //TipoDePagamento
 public void NovaVersaoParaExclusao(TipoDePagamento tipodepagamento, bool Atualizar = false)
 {
     (new Execute()).Sistema.Versao.CriarNovaVersao(new DOMINIO.Model.Sistema.Versao()
     {
         VersaoId   = Guid.NewGuid(),
         Momento    = DateTime.Now,
         Operacao   = "D",
         Entidade   = tipodepagamento.GetType().Name,
         EnitdadeId = tipodepagamento.TipoDePagamentoId.ToString(),
         Promotor   = tipodepagamento.AlteradoPor,
         Dados      = JsonConvert.SerializeObject(tipodepagamento)
     });
 }
Exemple #10
0
        public List <TipoDePagamento> AtualizarMuitosTiposDePagamentos(List <TipoDePagamento> tipodepagamentos)
        {
            List <TipoDePagamento> ret = null;

            try
            {
                ret = new List <TipoDePagamento>();
                foreach (TipoDePagamento item in tipodepagamentos)
                {
                    TipoDePagamento result = AtualizarTipoDePagamento(item);
                    ret.Add(result);
                }
            }
            catch
            {
            }
            return(ret);
        }
Exemple #11
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);
        }
Exemple #12
0
        public List <TipoDePagamento> CriarMuitosNovosTiposDePagamentos(List <TipoDePagamento> tipodepagamentos, bool Atualizar = false)
        {
            List <TipoDePagamento> ret = null;

            try
            {
                ret = new List <TipoDePagamento>();
                foreach (TipoDePagamento item in tipodepagamentos)
                {
                    TipoDePagamento result = CriarNovoTipoDePagamento(item, Atualizar);
                    if (result != null)
                    {
                        ret.Add(result);
                    }
                }
            }
            catch
            {
            }
            return(ret);
        }
Exemple #13
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);
        }
Exemple #14
0
        public static TipoDePagamento NovoTipoDePagamento(this IRepository <TipoDePagamento> repository, TipoDePagamento tipodepagamento)
        {
            tipodepagamento.TipoDePagamentoId = Guid.NewGuid();
            tipodepagamento.Ativo             = true;
            repository.Insert(tipodepagamento);

            return(tipodepagamento);
        }