public bool ExcluirTipoBloco(TipoBloco tipobloco) { bool ret = true; if (tipobloco == null) { return(false); } if (tipobloco.TipoBlocoId == Guid.Empty) { return(false); } try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoBloco> TipoBlocoRepository = new Repository <TipoBloco>(context, unitOfWork); ITipoBlocoService TipoBlocoService = new TipoBlocoService(TipoBlocoRepository); tipobloco.ObjectState = INFRAESTRUTURA.TRANSVERSAL.Core.States.ObjectState.Deleted; TipoBlocoService.Delete(tipobloco.TipoBlocoId); unitOfWork.SaveChanges(); (new Execute()).Sistema.Versao.NovaVersaoParaExclusao(tipobloco); } } catch { ret = false; } return(ret); }
public TipoBloco CriarNovoTipoBloco(TipoBloco tipobloco, bool Atualizar = false) { if (tipobloco == null) { tipobloco = new TipoBloco(); tipobloco.TipoBlocoId = Guid.Empty; } using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoBloco> TipoBlocoRepository = new Repository <TipoBloco>(context, unitOfWork); ITipoBlocoService TipoBlocoService = new TipoBlocoService(TipoBlocoRepository); if (!ExisteTipoBloco(tipobloco.TipoBlocoId)) { tipobloco = TipoBlocoService.NovoTipoBloco(tipobloco); unitOfWork.SaveChanges(); } else if (Atualizar) { tipobloco = AtualizarTipoBloco(tipobloco); unitOfWork.SaveChanges(); } unitOfWork.Dispose(); (new Execute()).Sistema.Versao.NovaVersaoParaCriacao(tipobloco); } return(tipobloco); }
public TipoBloco AtualizarTipoBloco(TipoBloco tipobloco) { if (tipobloco == null) { return(tipobloco); } using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoBloco> tipoblocoRepository = new Repository <TipoBloco>(context, unitOfWork); ITipoBlocoService tipoblocoService = new TipoBlocoService(tipoblocoRepository); tipobloco.ObjectState = INFRAESTRUTURA.TRANSVERSAL.Core.States.ObjectState.Modified; tipoblocoService.Update(tipobloco); unitOfWork.SaveChanges(); (new Execute()).Sistema.Versao.NovaVersaoParaEdicao(tipobloco); } return(tipobloco); }
public List <TipoBloco> BuscarTiposBlocos(string filtro) { List <TipoBloco> ret = null; try { ret = new List <TipoBloco>(); using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoBloco> tipoblocoRepository = new Repository <TipoBloco>(context, unitOfWork); ITipoBlocoService tipoblocoService = new TipoBlocoService(tipoblocoRepository); ret = tipoblocoService.BuscarTiposBlocos(filtro).ToList <TipoBloco>(); unitOfWork.Dispose(); } } catch { ret = null; } return(ret); }
public TipoBloco CarregarTipoBloco(Guid TipoBlocoId) { TipoBloco ret = null; try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoBloco> tipoblocoRepository = new Repository <TipoBloco>(context, unitOfWork); ITipoBlocoService tipoblocoService = new TipoBlocoService(tipoblocoRepository); ret = tipoblocoService.Find(TipoBlocoId); unitOfWork.Dispose(); } } catch { ret = null; } return(ret); }
public bool ExisteTipoBloco(Guid TipoBlocoId) { bool ret = false; try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <TipoBloco> tipoblocoRepository = new Repository <TipoBloco>(context, unitOfWork); ITipoBlocoService tipoblocoService = new TipoBlocoService(tipoblocoRepository); ret = (!(tipoblocoService.Find(TipoBlocoId) == null)); unitOfWork.Dispose(); } } catch { ret = false; } return(ret); }