diff --git a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs index a7683551..3461d811 100644 --- a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs +++ b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs @@ -89,9 +89,6 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService public async Task SaveMealShiftsAsync(List requests) { var shiftCode = requests[0].ShiftCode; - - await _dbContext.Deleteable().Where(x => x.ShiftCode == shiftCode).ExecuteCommandAsync(); - var shift = await CheckExistsShiftAsync(shiftCode); foreach (var request in requests) @@ -112,7 +109,10 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService } else { - var entity = await _dbContext.Queryable().FirstAsync(x => x.Id == request.Id); + var entity = await _dbContext.Queryable() + .Where(x => x.ShiftCode == shiftCode) + .SingleAsync(x => x.Id == request.Id); + entity.ThrowIfNull("餐次段不存在"); entity.Start = request.TimePeriod.Start.Value; @@ -258,7 +258,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService .Select(x => new TimePeriod { Start = x.Start, - End = x.End, + End = x.End }) .ToListAsync(); @@ -286,7 +286,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService private async Task CheckExistsShiftAsync(Guid shiftCode) { - var shift = await _dbContext.Queryable().Where(x => x.Code == shiftCode).FirstAsync(); + var shift = await _dbContext.Queryable().Where(x => x.Code == shiftCode).SingleAsync(); shift.ThrowIfNull("餐次不存在"); return shift;