Exemplo n.º 1
0
        public NccModule Update(NccModule entity)
        {
            var oldEntity = _entityRepository.Get(entity.Id);

            if (oldEntity != null)
            {
                using (var txn = _entityRepository.BeginTransaction())
                {
                    CopyNewData(oldEntity, entity);
                    _entityRepository.Edit(oldEntity);
                    _entityRepository.SaveChange();
                    txn.Commit();
                }
            }

            return(entity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Execure a raw SQL query
        /// </summary>
        /// <param name="query">Raw SQL query</param>
        /// <returns></returns>
        public string ExecuteQuery(NccDbQueryText query)
        {
            string retVal = "";

            using (var txn = _entityRepository.BeginTransaction())
            {
                try
                {
                    var ret = _entityRepository.ExecuteSqlCommand(query);
                    retVal = ret.ToString();
                    txn.Commit();
                }
                catch (Exception ex)
                {
                    txn.Rollback();
                }
            }

            return(retVal);
        }