批量删除

optimize
wanghaomei 1 year ago
parent 74b98408dd
commit 5182403d69

@ -357,19 +357,25 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 删除 /// 删除
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="ids"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("/BookingCustomerOrder/Delete")] [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); var list = await _rep.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id)).ToListAsync();
if (entity.BSSTATUS != "已录入" && entity.BSSTATUS != "已驳回")
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; list.ForEach(x =>
await _rep.UpdateAsync(entity); {
x.IsDeleted = true;
_rep.Update(x);
});
} }
#endregion #endregion

Loading…
Cancel
Save