Exemple #1
0
        // Insert
        public TModel Insert <TModel>(TModel obj)
            where TModel : BaseModel, new()
        {
            // Cache Remove.
            _cache.ClearInContains(typeof(TModel).Name);

            if (_session.Check())
            {
                // Audit Infos
                var user = _session.Get <SC_USER>(Strings.Authorization.UserSessionKey);
                if (user != null)
                {
                    obj.ModUser = user.IdUser;
                    obj.CreUser = user.IdUser;
                }
            }

            return(_repository.Insert(obj));
        }
        public TModel Insert <TModel>(TModel obj, IDbTransaction trans = null)
            where TModel : BaseModel, new()
        {
            if (_session.Check())
            {
                var user = _session.Get <SC_USER>(Strings.Authorization.UserSessionKey);

                if (user != null)
                {
                    obj.CreUser = user.IdUser;
                    obj.ModUser = user.IdUser;
                }
            }

            var id = _connection.Insert(obj, trans);

            obj = _connection.Get <TModel>(id, trans);
            return(obj);
        }