Example #1
0
 public Core(IRedisCache redisCache, AppSessionFactory appSessionFactory, IMemoryCache cache, ILogger <Core> logger)
 {
     this._redisCache        = redisCache;
     this._logger            = logger;
     this._cache             = cache;
     this._appSessionFactory = appSessionFactory;
 }
Example #2
0
        public Domain.CategoriaDomain Obter(int codigo)
        {
            using (ISession session = AppSessionFactory.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    transaction.Begin();
                    session.Get(typeof(CategoriaDomain), 1);
                    transaction.Commit();
                    session.Close();
                }

            return(categorias.Where(c => c.Codigo == codigo).FirstOrDefault());
        }
Example #3
0
        public void Salvar(Domain.CategoriaDomain categoria)
        {
            var categoriaSalva = Obter(categoria.Codigo);

            if (categoriaSalva == null)
            {
                using (ISession session = AppSessionFactory.OpenSession())
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        transaction.Begin();
                        session.Save(categoria);
                        transaction.Commit();
                        session.Close();
                    }
            }

            else
            {
                categoriaSalva.Nome = categoria.Nome;
            }
        }
Example #4
0
 public Startup(IConfiguration configuration)
 {
     Configuration     = configuration;
     appSessionFactory = new AppSessionFactory(Configuration, true);
 }
Example #5
0
 UsuarioRepository(AppSessionFactory session)
 {
 }
Example #6
0
 public SchemaModel(ISession session, AppSessionFactory applicationSession)
 {
     _applicationSession = applicationSession;
     _session            = session ?? throw new ArgumentNullException(nameof(session));
 }