using Admin.NET.Plugin.AiDOP.Dto.S0.Quality; using Admin.NET.Plugin.AiDOP.Entity.S0.Quality; using Admin.NET.Plugin.AiDOP.Infrastructure; using static Admin.NET.Plugin.AiDOP.Controllers.S0.Quality.AdoS0QmsControllerHelpers; namespace Admin.NET.Plugin.AiDOP.Controllers.S0.Quality; [ApiController] [Route("api/s0/quality/inspection-bases")] [AllowAnonymous] [NonUnify] public class AdoS0QmsInspectionBasesController : ControllerBase { private readonly SqlSugarRepository _rep; private readonly SqlSugarRepository _entryRep; public AdoS0QmsInspectionBasesController( SqlSugarRepository rep, SqlSugarRepository entryRep) { _rep = rep; _entryRep = entryRep; } [HttpGet] public async Task GetPagedAsync([FromQuery] AdoS0QualityPagedQueryDto q) { (q.Page, q.PageSize) = PagingGuard.Normalize(q.Page, q.PageSize); var query = _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(q.Keyword), x => (x.Number != null && x.Number.Contains(q.Keyword!)) || (x.Name != null && x.Name.Contains(q.Keyword!))); var total = await query.CountAsync(); var list = await query.OrderBy(x => x.Number).Skip((q.Page - 1) * q.PageSize).Take(q.PageSize).ToListAsync(); return Ok(new { total, page = q.Page, pageSize = q.PageSize, list }); } [HttpGet("{id:long}")] public async Task GetDetailAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var items = await _entryRep.AsQueryable().Where(x => x.MasterId == id).OrderBy(x => x.Seq).OrderBy(x => x.Id).ToListAsync(); return Ok(new { master, items }); } [HttpGet("options")] public async Task GetOptionsAsync() => Ok(await _rep.AsQueryable() .OrderBy(x => x.Number) .Select(x => new AdoS0QualitySimpleOptionDto { Value = x.Id, Label = (x.Number ?? "") + " / " + (x.Name ?? "") }) .ToListAsync()); [HttpPost] public async Task CreateAsync([FromBody] AdoS0QmsInspectionBasisUpsertDto dto) { var db = _rep.Context; await db.Ado.BeginTranAsync(); try { var master = new AdoS0QmsInspectionBasis(); ApplyInspectionBasis(master, dto, true); await _rep.AsInsertable(master).ExecuteReturnEntityAsync(); await SyncInspectionBasisEntriesAsync(master.Id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(master.Id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpPut("{id:long}")] public async Task UpdateAsync(long id, [FromBody] AdoS0QmsInspectionBasisUpsertDto dto) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { ApplyInspectionBasis(master, dto, false); await _rep.AsUpdateable(master).ExecuteCommandAsync(); await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await SyncInspectionBasisEntriesAsync(id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpDelete("{id:long}")] public async Task DeleteAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await _rep.DeleteAsync(master); await db.Ado.CommitTranAsync(); return Ok(new { message = "删除成功" }); } catch { await db.Ado.RollbackTranAsync(); throw; } } private static void ApplyInspectionBasis(AdoS0QmsInspectionBasis entity, AdoS0QmsInspectionBasisUpsertDto dto, bool isCreate) { entity.Number = dto.Number.Trim(); entity.Name = dto.Name.Trim(); entity.ControlStrategy = NullIfWhiteSpace(dto.ControlStrategy); entity.CreateOrgId = dto.CreateOrgId; entity.UseOrgId = dto.UseOrgId; entity.Comment = NullIfWhiteSpace(dto.Comment); entity.Status = NullIfWhiteSpace(dto.Status); entity.EnableStatus = NullIfWhiteSpace(dto.EnableStatus); if (isCreate) entity.CreateTime = DateTime.Now; entity.ModifyTime = DateTime.Now; } private async Task SyncInspectionBasisEntriesAsync(long masterId, IEnumerable items) { var seq = 1L; foreach (var item in items) { var entity = new AdoS0QmsInspectionBasisEntry { MasterId = masterId, Seq = item.Seq ?? seq++, DocumentNumber = NullIfWhiteSpace(item.DocumentNumber), DocumentName = NullIfWhiteSpace(item.DocumentName), Attachment = NullIfWhiteSpace(item.Attachment) }; await _entryRep.AsInsertable(entity).ExecuteCommandAsync(); } } } [ApiController] [Route("api/s0/quality/inspection-standards")] [AllowAnonymous] [NonUnify] public class AdoS0QmsInspectionStandardsController : ControllerBase { private readonly SqlSugarRepository _rep; private readonly SqlSugarRepository _entryRep; public AdoS0QmsInspectionStandardsController( SqlSugarRepository rep, SqlSugarRepository entryRep) { _rep = rep; _entryRep = entryRep; } [HttpGet] public async Task GetPagedAsync([FromQuery] AdoS0QualityPagedQueryDto q) { (q.Page, q.PageSize) = PagingGuard.Normalize(q.Page, q.PageSize); var query = _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(q.Keyword), x => (x.Number != null && x.Number.Contains(q.Keyword!)) || (x.Name != null && x.Name.Contains(q.Keyword!))); var total = await query.CountAsync(); var list = await query.OrderBy(x => x.Number).Skip((q.Page - 1) * q.PageSize).Take(q.PageSize).ToListAsync(); return Ok(new { total, page = q.Page, pageSize = q.PageSize, list }); } [HttpGet("{id:long}")] public async Task GetDetailAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var items = await _entryRep.AsQueryable().Where(x => x.MasterId == id).OrderBy(x => x.Seq).OrderBy(x => x.Id).ToListAsync(); return Ok(new { master, items }); } [HttpGet("options")] public async Task GetOptionsAsync() => Ok(await _rep.AsQueryable() .OrderBy(x => x.Number) .Select(x => new AdoS0QualitySimpleOptionDto { Value = x.Id, Label = (x.Number ?? "") + " / " + (x.Name ?? "") }) .ToListAsync()); [HttpPost] public async Task CreateAsync([FromBody] AdoS0QmsInspectionStandardUpsertDto dto) { var db = _rep.Context; await db.Ado.BeginTranAsync(); try { var master = new AdoS0QmsInspectionStandard(); ApplyInspectionStandard(master, dto); await _rep.AsInsertable(master).ExecuteReturnEntityAsync(); await SyncInspectionStandardEntriesAsync(master.Id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(master.Id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpPut("{id:long}")] public async Task UpdateAsync(long id, [FromBody] AdoS0QmsInspectionStandardUpsertDto dto) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { ApplyInspectionStandard(master, dto); await _rep.AsUpdateable(master).ExecuteCommandAsync(); await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await SyncInspectionStandardEntriesAsync(id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpDelete("{id:long}")] public async Task DeleteAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await _rep.DeleteAsync(master); await db.Ado.CommitTranAsync(); return Ok(new { message = "删除成功" }); } catch { await db.Ado.RollbackTranAsync(); throw; } } private static void ApplyInspectionStandard(AdoS0QmsInspectionStandard entity, AdoS0QmsInspectionStandardUpsertDto dto) { entity.Number = dto.Number.Trim(); entity.Name = dto.Name.Trim(); entity.Comment = NullIfWhiteSpace(dto.Comment); entity.ControlStrategy = NullIfWhiteSpace(dto.ControlStrategy); entity.CreateOrgId = dto.CreateOrgId; entity.UseOrgId = dto.UseOrgId; entity.Status = NullIfWhiteSpace(dto.Status); entity.EnableStatus = NullIfWhiteSpace(dto.EnableStatus); } private async Task SyncInspectionStandardEntriesAsync(long masterId, IEnumerable items) { var seq = 1L; foreach (var item in items) { var entity = new AdoS0QmsInspectionStandardEntry { MasterId = masterId, Seq = item.Seq ?? seq++, CheckItems = NullIfWhiteSpace(item.CheckItems), CheckContent = NullIfWhiteSpace(item.CheckContent), NormType = NullIfWhiteSpace(item.NormType), SpecValue = NullIfWhiteSpace(item.SpecValue), TopValue = item.TopValue, DownValue = item.DownValue, CheckBasisId = item.CheckBasisId, CheckMethodId = item.CheckMethodId, CheckFrequencyId = item.CheckFrequencyId, CheckInstructId = item.CheckInstructId, Unit = NullIfWhiteSpace(item.Unit), KeyQuality = item.KeyQuality }; await _entryRep.AsInsertable(entity).ExecuteCommandAsync(); } } } [ApiController] [Route("api/s0/quality/inspection-plans")] [AllowAnonymous] [NonUnify] public class AdoS0QmsInspectionPlansController : ControllerBase { private readonly SqlSugarRepository _rep; private readonly SqlSugarRepository _entryRep; public AdoS0QmsInspectionPlansController( SqlSugarRepository rep, SqlSugarRepository entryRep) { _rep = rep; _entryRep = entryRep; } [HttpGet] public async Task GetPagedAsync([FromQuery] AdoS0QualityPagedQueryDto q) { (q.Page, q.PageSize) = PagingGuard.Normalize(q.Page, q.PageSize); var query = _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(q.Keyword), x => (x.Number != null && x.Number.Contains(q.Keyword!)) || (x.Name != null && x.Name.Contains(q.Keyword!))); var total = await query.CountAsync(); var list = await query.OrderBy(x => x.Number).Skip((q.Page - 1) * q.PageSize).Take(q.PageSize).ToListAsync(); return Ok(new { total, page = q.Page, pageSize = q.PageSize, list }); } [HttpGet("{id:long}")] public async Task GetDetailAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var items = await _entryRep.AsQueryable().Where(x => x.MasterId == id).OrderBy(x => x.Seq).OrderBy(x => x.Id).ToListAsync(); return Ok(new { master, items }); } [HttpPost] public async Task CreateAsync([FromBody] AdoS0QmsInspectionPlanUpsertDto dto) { var db = _rep.Context; await db.Ado.BeginTranAsync(); try { var master = new AdoS0QmsInspectionPlan(); ApplyInspectionPlan(master, dto, true); await _rep.AsInsertable(master).ExecuteReturnEntityAsync(); await SyncInspectionPlanEntriesAsync(master.Id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(master.Id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpPut("{id:long}")] public async Task UpdateAsync(long id, [FromBody] AdoS0QmsInspectionPlanUpsertDto dto) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { ApplyInspectionPlan(master, dto, false); await _rep.AsUpdateable(master).ExecuteCommandAsync(); await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await SyncInspectionPlanEntriesAsync(id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpDelete("{id:long}")] public async Task DeleteAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await _rep.DeleteAsync(master); await db.Ado.CommitTranAsync(); return Ok(new { message = "删除成功" }); } catch { await db.Ado.RollbackTranAsync(); throw; } } private static void ApplyInspectionPlan(AdoS0QmsInspectionPlan entity, AdoS0QmsInspectionPlanUpsertDto dto, bool isCreate) { entity.Number = dto.Number.Trim(); entity.Name = dto.Name.Trim(); entity.BizTypeId = NullIfWhiteSpace(dto.BizTypeId); entity.Comment = NullIfWhiteSpace(dto.Comment); entity.ControlStrategy = NullIfWhiteSpace(dto.ControlStrategy); entity.CreateOrgId = dto.CreateOrgId; entity.UseOrgId = dto.UseOrgId; entity.Status = NullIfWhiteSpace(dto.Status); entity.EnableStatus = NullIfWhiteSpace(dto.EnableStatus); if (isCreate) entity.CreateTime = DateTime.Now; entity.ModifyTime = DateTime.Now; } private async Task SyncInspectionPlanEntriesAsync(long masterId, IEnumerable items) { var seq = 1; foreach (var item in items) { var entity = new AdoS0QmsInspectionPlanEntry { MasterId = masterId, Seq = item.Seq ?? seq++, SetupType = NullIfWhiteSpace(item.SetupType), MaterialCode = NullIfWhiteSpace(item.MaterialCode), MaterialName = NullIfWhiteSpace(item.MaterialName), MaterialTypeId = item.MaterialTypeId, SupplierId = NullIfWhiteSpace(item.SupplierId), SamplingSchemeId = item.SamplingSchemeId, InspectionStandardId = item.InspectionStandardId, InspectOrgId = item.InspectOrgId, InspectUserId = item.InspectUserId, QRouteId = item.QRouteId, OperationNo = NullIfWhiteSpace(item.OperationNo), OperationId = item.OperationId, InspectionFrequencyId = item.InspectionFrequencyId, ProcessSeq = NullIfWhiteSpace(item.ProcessSeq), InspectionType = item.InspectionType }; await _entryRep.AsInsertable(entity).ExecuteCommandAsync(); } } } [ApiController] [Route("api/s0/quality/raw-inspection-specs")] [AllowAnonymous] [NonUnify] public class AdoS0QmsRawInspectionSpecsController : ControllerBase { private readonly SqlSugarRepository _rep; private readonly SqlSugarRepository _entryRep; public AdoS0QmsRawInspectionSpecsController( SqlSugarRepository rep, SqlSugarRepository entryRep) { _rep = rep; _entryRep = entryRep; } [HttpGet] public async Task GetPagedAsync([FromQuery] AdoS0QualityPagedQueryDto q) { (q.Page, q.PageSize) = PagingGuard.Normalize(q.Page, q.PageSize); var query = _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(q.Keyword), x => (x.FileNumber != null && x.FileNumber.Contains(q.Keyword!)) || (x.RawMaterialName != null && x.RawMaterialName.Contains(q.Keyword!)) || (x.MaterialCode != null && x.MaterialCode.Contains(q.Keyword!))); var total = await query.CountAsync(); var list = await query.OrderByDescending(x => x.Id).Skip((q.Page - 1) * q.PageSize).Take(q.PageSize).ToListAsync(); return Ok(new { total, page = q.Page, pageSize = q.PageSize, list }); } [HttpGet("{id:long}")] public async Task GetDetailAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var items = await _entryRep.AsQueryable().Where(x => x.MasterId == id).OrderBy(x => x.Seq).OrderBy(x => x.Id).ToListAsync(); return Ok(new { master, items }); } [HttpPost] public async Task CreateAsync([FromBody] AdoS0QmsRawInspectionSpecUpsertDto dto) { var db = _rep.Context; await db.Ado.BeginTranAsync(); try { var master = new AdoS0QmsRawInspectionSpec(); ApplyRawInspectionSpec(master, dto); await _rep.AsInsertable(master).ExecuteReturnEntityAsync(); await SyncRawInspectionSpecEntriesAsync(master.Id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(master.Id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpPut("{id:long}")] public async Task UpdateAsync(long id, [FromBody] AdoS0QmsRawInspectionSpecUpsertDto dto) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { ApplyRawInspectionSpec(master, dto); await _rep.AsUpdateable(master).ExecuteCommandAsync(); await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await SyncRawInspectionSpecEntriesAsync(id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpDelete("{id:long}")] public async Task DeleteAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await _rep.DeleteAsync(master); await db.Ado.CommitTranAsync(); return Ok(new { message = "删除成功" }); } catch { await db.Ado.RollbackTranAsync(); throw; } } private static void ApplyRawInspectionSpec(AdoS0QmsRawInspectionSpec entity, AdoS0QmsRawInspectionSpecUpsertDto dto) { entity.FileNumber = dto.FileNumber.Trim(); entity.VersionNo = NullIfWhiteSpace(dto.VersionNo); entity.DrawingNo = NullIfWhiteSpace(dto.DrawingNo); entity.RawMaterialName = NullIfWhiteSpace(dto.RawMaterialName); entity.MaterialCode = NullIfWhiteSpace(dto.MaterialCode); entity.EffectiveDate = NullIfWhiteSpace(dto.EffectiveDate); entity.DrawingVersion = NullIfWhiteSpace(dto.DrawingVersion); entity.MaterialGrade = NullIfWhiteSpace(dto.MaterialGrade); entity.CavityOrMold = NullIfWhiteSpace(dto.CavityOrMold); entity.Attachment = NullIfWhiteSpace(dto.Attachment); entity.FileName = NullIfWhiteSpace(dto.FileName); entity.Title = NullIfWhiteSpace(dto.Title); } private async Task SyncRawInspectionSpecEntriesAsync(long masterId, IEnumerable items) { var seq = 1; foreach (var item in items) { var entity = new AdoS0QmsRawInspectionSpecEntry { MasterId = masterId, Seq = item.Seq ?? seq++, InspectionItem = NullIfWhiteSpace(item.InspectionItem), InspectionStandard = NullIfWhiteSpace(item.InspectionStandard), InspectionMethod = NullIfWhiteSpace(item.InspectionMethod), ImageCategory = NullIfWhiteSpace(item.ImageCategory), SamplingScheme = NullIfWhiteSpace(item.SamplingScheme), Remark = NullIfWhiteSpace(item.Remark), Attachment = NullIfWhiteSpace(item.Attachment), UpperLimit = NullIfWhiteSpace(item.UpperLimit), LowerLimit = NullIfWhiteSpace(item.LowerLimit) }; await _entryRep.AsInsertable(entity).ExecuteCommandAsync(); } } } [ApiController] [Route("api/s0/quality/process-inspection-specs")] [AllowAnonymous] [NonUnify] public class AdoS0QmsProcessInspectionSpecsController : ControllerBase { private readonly SqlSugarRepository _rep; private readonly SqlSugarRepository _entryRep; public AdoS0QmsProcessInspectionSpecsController( SqlSugarRepository rep, SqlSugarRepository entryRep) { _rep = rep; _entryRep = entryRep; } [HttpGet] public async Task GetPagedAsync([FromQuery] AdoS0QualityPagedQueryDto q) { (q.Page, q.PageSize) = PagingGuard.Normalize(q.Page, q.PageSize); var query = _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(q.Keyword), x => (x.FileNumber != null && x.FileNumber.Contains(q.Keyword!)) || (x.ApplicableModel != null && x.ApplicableModel.Contains(q.Keyword!)) || (x.MaterialCode != null && x.MaterialCode.Contains(q.Keyword!))); var total = await query.CountAsync(); var list = await query.OrderByDescending(x => x.Id).Skip((q.Page - 1) * q.PageSize).Take(q.PageSize).ToListAsync(); return Ok(new { total, page = q.Page, pageSize = q.PageSize, list }); } [HttpGet("{id:long}")] public async Task GetDetailAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var items = await _entryRep.AsQueryable().Where(x => x.MasterId == id).OrderBy(x => x.Id).ToListAsync(); return Ok(new { master, items }); } [HttpPost] public async Task CreateAsync([FromBody] AdoS0QmsProcessInspectionSpecUpsertDto dto) { var db = _rep.Context; await db.Ado.BeginTranAsync(); try { var master = new AdoS0QmsProcessInspectionSpec(); ApplyProcessInspectionSpec(master, dto); await _rep.AsInsertable(master).ExecuteReturnEntityAsync(); await SyncProcessInspectionSpecEntriesAsync(master.Id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(master.Id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpPut("{id:long}")] public async Task UpdateAsync(long id, [FromBody] AdoS0QmsProcessInspectionSpecUpsertDto dto) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { ApplyProcessInspectionSpec(master, dto); await _rep.AsUpdateable(master).ExecuteCommandAsync(); await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await SyncProcessInspectionSpecEntriesAsync(id, dto.Items); await db.Ado.CommitTranAsync(); return await GetDetailAsync(id); } catch { await db.Ado.RollbackTranAsync(); throw; } } [HttpDelete("{id:long}")] public async Task DeleteAsync(long id) { var master = await _rep.GetByIdAsync(id); if (master == null) return NotFound(); var db = _rep.Context; await db.Ado.BeginTranAsync(); try { await _entryRep.AsDeleteable().Where(x => x.MasterId == id).ExecuteCommandAsync(); await _rep.DeleteAsync(master); await db.Ado.CommitTranAsync(); return Ok(new { message = "删除成功" }); } catch { await db.Ado.RollbackTranAsync(); throw; } } private static void ApplyProcessInspectionSpec(AdoS0QmsProcessInspectionSpec entity, AdoS0QmsProcessInspectionSpecUpsertDto dto) { entity.ApplicableModel = NullIfWhiteSpace(dto.ApplicableModel); entity.FileNumber = dto.FileNumber.Trim(); entity.VersionNo = NullIfWhiteSpace(dto.VersionNo); entity.EffectiveDate = NullIfWhiteSpace(dto.EffectiveDate); entity.Attachment = NullIfWhiteSpace(dto.Attachment); entity.MaterialCode = NullIfWhiteSpace(dto.MaterialCode); entity.Attachment2 = NullIfWhiteSpace(dto.Attachment2); entity.Version = dto.Version; } private async Task SyncProcessInspectionSpecEntriesAsync(long masterId, IEnumerable items) { foreach (var item in items) { var entity = new AdoS0QmsProcessInspectionSpecEntry { MasterId = masterId, OperationCode = NullIfWhiteSpace(item.OperationCode), OperationName = NullIfWhiteSpace(item.OperationName), InspectionItem = NullIfWhiteSpace(item.InspectionItem), InspectionMethod = NullIfWhiteSpace(item.InspectionMethod), InspectionSpec = NullIfWhiteSpace(item.InspectionSpec), ImageCategory = NullIfWhiteSpace(item.ImageCategory), InspectionFrequency = NullIfWhiteSpace(item.InspectionFrequency), TechnicalStandard = NullIfWhiteSpace(item.TechnicalStandard), PeelingForce = item.PeelingForce, UpperLimit = NullIfWhiteSpace(item.UpperLimit), LowerLimit = NullIfWhiteSpace(item.LowerLimit) }; await _entryRep.AsInsertable(entity).ExecuteCommandAsync(); } } }