增加重置箱接口

This commit is contained in:
18942506660
2024-05-15 15:17:02 +08:00
parent 5d31f820e0
commit e4dea40c01
8 changed files with 174 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using NPOI.OpenXmlFormats.Spreadsheet;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -177,5 +178,36 @@ namespace WMS.Web.Repositories
return res.Clone();
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="billNos"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<bool> DeleteEntityList(List<int> boxIds, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
var res = await _context.Box
.Include(s => s.Details)
.Where(f => boxIds.Contains(f.Id)).ToListAsync();
_context.Box.RemoveRange(res);
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
return true;
}
}
}