public bool ExisteRegra(Guid RegraId) { bool ret = false; try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Regra> regraRepository = new Repository <Regra>(context, unitOfWork); IRegraService regraService = new RegraService(regraRepository); ret = (!(regraService.Find(RegraId) == null)); unitOfWork.Dispose(); } } catch { ret = false; } return(ret); }
public Regra CarregarRegra(Guid RegraId) { Regra ret = null; try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Regra> regraRepository = new Repository <Regra>(context, unitOfWork); IRegraService regraService = new RegraService(regraRepository); ret = regraService.Find(RegraId); unitOfWork.Dispose(); } } catch { ret = null; } return(ret); }