箱信息增加软删除
This commit is contained in:
@@ -77,7 +77,7 @@ namespace WMS.Web.Repositories
|
||||
public async Task<Box> Get(int id)
|
||||
{
|
||||
var entity = await _context.Box.Include(x => x.Details)
|
||||
.FirstOrDefaultAsync(f => f.Id.Equals(id));
|
||||
.FirstOrDefaultAsync(f => f.Id.Equals(id) && f.IsDelete != true);
|
||||
|
||||
return entity.Clone();
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace WMS.Web.Repositories
|
||||
/// <returns></returns>
|
||||
public async Task<List<BoxResponse>> GetBox(List<string> BoxBillNos)
|
||||
{
|
||||
var list = await _context.Box.Include(x => x.Details).Where(f => BoxBillNos.Contains(f.BoxBillNo.ToLower())).ToListAsync();
|
||||
var list = await _context.Box.Include(x => x.Details).Where(f => BoxBillNos.Contains(f.BoxBillNo.ToLower()) && f.IsDelete != true).ToListAsync();
|
||||
var resList = _mapper.Map<List<BoxResponse>>(list);
|
||||
|
||||
var materials_result = await _erpService.BillQueryForMaterial();
|
||||
@@ -153,14 +153,14 @@ namespace WMS.Web.Repositories
|
||||
public async Task<Box> GetByNo(string billNo)
|
||||
{
|
||||
var entity = await _context.Box.Include(x => x.Details)
|
||||
.FirstOrDefaultAsync(f => f.BoxBillNo.Equals(billNo));
|
||||
.FirstOrDefaultAsync(f => f.BoxBillNo.Equals(billNo) && f.IsDelete != true);
|
||||
|
||||
return entity.Clone();
|
||||
}
|
||||
public async Task<List<Box>> GetEntityListByNos(List<string> billNos)
|
||||
{
|
||||
var entity = await _context.Box.Include(x => x.Details)
|
||||
.Where(f => billNos.Contains(f.BoxBillNo)).ToListAsync();
|
||||
.Where(f => billNos.Contains(f.BoxBillNo) && f.IsDelete != true).ToListAsync();
|
||||
|
||||
return entity.Clone();
|
||||
}
|
||||
@@ -168,7 +168,7 @@ namespace WMS.Web.Repositories
|
||||
public async Task<List<string>> GetByNos(List<string> billNos)
|
||||
{
|
||||
return await _context.Box
|
||||
.Where(w => billNos.Contains(w.BoxBillNo)).Select(s => s.BoxBillNo).ToListAsync();
|
||||
.Where(w => billNos.Contains(w.BoxBillNo) && w.IsDelete != true).Select(s => s.BoxBillNo).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> AddRange(List<Box> entitys, bool isTransaction = true)
|
||||
@@ -203,41 +203,11 @@ namespace WMS.Web.Repositories
|
||||
{
|
||||
var res = await _context.Box
|
||||
.Include(s => s.Details)
|
||||
.Where(f => ids.Contains(f.Id))
|
||||
.Where(f => ids.Contains(f.Id) && f.IsDelete != true)
|
||||
.ToListAsync();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user