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 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); }
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 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); }
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); }
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); }
public static TipoDePagamentoView DeDominParaView(this TipoDePagamento source) { TipoDePagamentoView tipodepagamento = new TipoDePagamentoView() { TipoDePagamentoId = source.TipoDePagamentoId, Descricao = source.Descricao, Ativo = source.Ativo }; return(tipodepagamento); }
public static TipoDePagamento DeViewParaDomin(this TipoDePagamentoView source) { TipoDePagamento tipodepagamento = new TipoDePagamento() { TipoDePagamentoId = source.TipoDePagamentoId, Descricao = source.Descricao, Ativo = source.Ativo }; return(tipodepagamento); }
//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) }); }
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); }
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> 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); }
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 static TipoDePagamento NovoTipoDePagamento(this IRepository <TipoDePagamento> repository, TipoDePagamento tipodepagamento) { tipodepagamento.TipoDePagamentoId = Guid.NewGuid(); tipodepagamento.Ativo = true; repository.Insert(tipodepagamento); return(tipodepagamento); }