示例#1
0
        /// <summary>
        /// 删除主事实
        /// </summary>
        /// <param name="factID"></param>
        /// <returns></returns>
        public IRAPError DeleteToRecycleByFactID(long factID)
        {
            //移动到Recycle
            var list = GetEntities <FactEntity>().Where(c => c.PartitioningKey == TempFactPK && c.FactID == factID);
            int i    = 0;

            foreach (var r in list)
            {
                RecycleFactEntity t2 = new RecycleFactEntity();
                r.CopyTo(t2);
                t2.Remark = t2.Remark + "[删除]";
                _db.Set <RecycleFactEntity>().Add(t2);
                _db.Set <FactEntity>().Remove(r);
                i++;
            }
            if (i == 0)
            {
                return(new IRAPError(11, "交易没有对应的事实记录!"));
            }
            SaveChanges();
            return(new IRAPError(0, "事实删除成功!"));
        }
示例#2
0
        /// <summary>
        /// 交易撤销到回收站
        /// </summary>
        /// <param name="transactNo"></param>
        /// <returns></returns>
        public IRAPError DeleteToRecycle(long transactNo)
        {
            TransactEntity t1 = GetEntities <TransactEntity>().FirstOrDefault(c => c.PartitioningKey == TransPK && c.TransactNo == transactNo);

            if (t1 == null)
            {
                throw new Exception($"交易号:{t1.TransactNo} 不存在!");
            }
            if (t1.Status > 3)
            {
                throw new Exception($"交易号:{t1.TransactNo} 已被撤销或已被固化!{t1.Status}");
            }
            t1.Revoker    = log.UserCode;
            t1.RevokeTime = DateTime.Now;
            t1.Status     = 4;
            //移动到Recycle
            var list = GetEntities <FactEntity>().Where(c => c.PartitioningKey == TempFactPK && c.TransactNo == transactNo);

            int i = 0;

            foreach (var r in list)
            {
                RecycleFactEntity t2 = new RecycleFactEntity();
                r.CopyTo(t2);
                t2.Remark = t2.Remark + "[撤销]";
                _db.Set <RecycleFactEntity>().Add(t2);
                _db.Set <FactEntity>().Remove(r);
                i++;
            }
            if (i == 0)
            {
                return(new IRAPError(11, "交易没有对应的事实记录!"));
            }
            SaveChanges();
            return(new IRAPError(0, "交易撤销成功!"));
        }