| | |
| | | /// <summary> |
| | | /// 插入拓展 |
| | | /// </summary> |
| | | public long InsertEx(Entity.XhsProject project, Entity.XhsProjectSite site) |
| | | public long InsertEx(Entity.XhsProject entityProject, List<Entity.XhsProjectSite> entityProjectSiteList) |
| | | { |
| | | if (project == null) |
| | | if (entityProject == null) |
| | | { |
| | | return default; |
| | | } |
| | |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | if (project.ID < 1) |
| | | if (entityProject.ID < 1) |
| | | { |
| | | project.ID = db.Insertable(project).ExecuteReturnSnowflakeId(); |
| | | if (project.ID < 1) |
| | | entityProject.ID = db.Insertable(entityProject).ExecuteReturnSnowflakeId(); |
| | | if (entityProject.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | |
| | | } |
| | | else |
| | | { |
| | | var bol = db.Insertable(project).ExecuteCommand() > 0; |
| | | var bol = db.Insertable(entityProject).ExecuteCommand() > 0; |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | |
| | | } |
| | | } |
| | | |
| | | if (site != null) |
| | | if (entityProjectSiteList != null && entityProjectSiteList.Count > 0) |
| | | { |
| | | site.ProjectID = project.ID; |
| | | if (site.ID < 1) |
| | | foreach (var entityProjectSite in entityProjectSiteList) |
| | | { |
| | | site.ID = db.Insertable(site).ExecuteReturnSnowflakeId(); |
| | | if (site.ID < 1) |
| | | entityProjectSite.ProjectID = entityProject.ID; |
| | | if (entityProjectSite.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | entityProjectSite.ID = db.Insertable(entityProjectSite).ExecuteReturnSnowflakeId(); |
| | | if (entityProjectSite.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var bol = db.Insertable(site).ExecuteCommand() >= 0; |
| | | if (!bol) |
| | | else |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | var bol = db.Insertable(entityProjectSite).ExecuteCommand() >= 0; |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return project.ID; |
| | | db.CommitTran(); |
| | | return entityProject.ID; |
| | | } |
| | | catch |
| | | { |
| | |
| | | /// <summary> |
| | | /// 编辑拓展 |
| | | /// </summary> |
| | | public bool UpdateEx(Entity.XhsProject project, Entity.XhsProjectSite site) |
| | | public bool UpdateEx(Entity.XhsProject entityProject, List<Entity.XhsProjectSite> entityProjectSiteList) |
| | | { |
| | | if (project == null) |
| | | if (entityProject == null) |
| | | { |
| | | return false; |
| | | } |
| | | if (project.ID < 1) |
| | | if (entityProject.ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var bol = db.Updateable(project).ExecuteCommandHasChange(); |
| | | var bol = db.Updateable(entityProject).ExecuteCommandHasChange(); |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | } |
| | | if (site != null) |
| | | if (entityProjectSiteList != null && entityProjectSiteList.Count > 0) |
| | | { |
| | | site.ProjectID = project.ID; |
| | | if (site.ID < 1) |
| | | foreach (var entityProjectSite in entityProjectSiteList) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | } |
| | | bol = db.Updateable(site).ExecuteCommandHasChange(); |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | entityProjectSite.ProjectID = entityProject.ID; |
| | | if (entityProjectSite.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | } |
| | | bol = db.Updateable(entityProjectSite).ExecuteCommandHasChange(); |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | db.CommitTran(); |
| | | return true; |
| | | } |
| | | catch |