diff --git a/Tiobon.Core.Services/Ghre/Ghre_TeacherChangeServices.cs b/Tiobon.Core.Services/Ghre/Ghre_TeacherChangeServices.cs index b7d0e816..08e25cbf 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_TeacherChangeServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_TeacherChangeServices.cs @@ -167,6 +167,44 @@ public class Ghre_TeacherChangeServices : BaseServices(); + teacher.Id = editModel.TeacherId.Value; + await Db.Updateable(teacher).UpdateColumns(it => new { it.TeacherLevel, it.Price, it.SkillPoints }).ExecuteCommandAsync(); + + var teacherAttachmentIds = await Db.Queryable().Where(x => x.TeacherId == editModel.TeacherId).Select(x => x.Id).ToListAsync(); + if (teacherAttachmentIds.Any()) + await Db.Updateable() + .SetColumns(it => new Ghre_TeacherAttachment() + { + IsEnable = 0 + }) + .Where(it => teacherAttachmentIds.Contains(it.Id)) + .ExecuteCommandAsync(); + + if (editModel.TeacherAttachments != null && editModel.TeacherAttachments.Any()) + { + for (int i = 0; i < editModel.TeacherAttachments.Count; i++) + { + var insert = Mapper.Map(editModel.TeacherAttachments[i]).ToANew(); ; + insert.TeacherId = teacher.Id; + var teacherAttachmentId = await _ghre_TeacherAttachmentServices.Add(insert); + if (editModel.TeacherAttachments[i].Attachments != null && editModel.TeacherAttachments[i].Attachments.Any()) + for (int j = 0; j < editModel.TeacherAttachments[i].Attachments.Count; j++) + { + var attachment = await Db.Queryable().FirstAsync(x => x.RelativePath == insert.Attachments[j].RelativePath); + attachment.TableName = teacherAttachmentId.ToString(); + await Db.Insertable(attachment).ExecuteReturnSnowflakeIdAsync(); + } + } + } + } + #endregion + return result; } public async Task> InsertByStatus(InsertGhre_TeacherChangeInput insertModel, string status)