批量删除

optimize
wanghaomei 1 year ago
parent 74b98408dd
commit 5182403d69

@ -357,19 +357,25 @@ namespace Myshipping.Application
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <param name="ids"></param>
/// <returns></returns>
[HttpPost("/BookingCustomerOrder/Delete")]
public async Task Delete(long id)
public async Task Delete(List<long> ids)
{
var entity = await _rep.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id);
if (entity.BSSTATUS != "已录入" && entity.BSSTATUS != "已驳回")
var list = await _rep.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id)).ToListAsync();
var canNotDelList = list.Where(x => x.BSSTATUS != "已录入" && x.BSSTATUS != "已驳回");
if (canNotDelList.Any())
{
throw Oops.Bah("当前状态不能删除");
var errMsg = string.Join("\r\n", canNotDelList.Select(x => $"{x.BOOKINGNO}的数据当前状态不能删除").ToList());
throw Oops.Bah(errMsg);
}
entity.IsDeleted = true;
await _rep.UpdateAsync(entity);
list.ForEach(x =>
{
x.IsDeleted = true;
_rep.Update(x);
});
}
#endregion

Loading…
Cancel
Save