lixiaojun
2024-12-10 a5872f7ed264a634c809b026d4d181f99a78db1d
Service/HStation.Service.Xhs.Core/04-dal/03-sqlite/XhsProject.cs
@@ -137,65 +137,6 @@
            }
        }
        /// <summary>
        /// 更新开始时间
        /// </summary>
        public virtual bool UpdateStartTime(long ID, DateTime StartTime)
        {
            using (SqlSugarClient db = new(ConnectionConfig))
            {
                return db.Updateable<Entity.XhsProject>()
                    .SetColumns(x => x.StartTime == StartTime)
                    .Where(x => x.ID == ID)
                    .ExecuteCommand() > 0;
            }
        }
        /// <summary>
        /// 更新结束时间
        /// </summary>
        public virtual bool UpdateEndTime(long ID, DateTime EndTime)
        {
            using (SqlSugarClient db = new(ConnectionConfig))
            {
                return db.Updateable<Entity.XhsProject>()
                    .SetColumns(x => x.EndTime == EndTime)
                    .Where(x => x.ID == ID)
                    .ExecuteCommand() > 0;
            }
        }
        /// <summary>
        /// 通过 ID 删除 (拓展)
        /// </summary>
        public bool DeleteExByID(long ID)
        {
            if (ID < 1)
            {
                return false;
            }
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                try
                {
                    db.BeginTran();
                    var bol = db.Deleteable<Entity.XhsProject>().Where(x => x.ID == ID).ExecuteCommandHasChange();
                    if (!bol)
                    {
                        db.RollbackTran();
                        return false;
                    }
                    db.Deleteable<Entity.XhsProjectSite>().Where(x => x.ProjectID == ID).ExecuteCommandHasChange();
                    db.CommitTran();
                    return true;
                }
                catch
                {
                    db.RollbackTran();
                    throw;
                }
            }
        }
    }