This commit is contained in:
tanglong 2025-07-02 14:17:04 +08:00
parent 1732e02b48
commit db301ead3c

View File

@ -145,8 +145,14 @@ namespace YD_AllHeartRates.Api.Services.Impl
{ {
var student = await _sportsContext.Student.Where(x => x.StudentNo == dto.StudentNo).FirstOrDefaultAsync(); var student = await _sportsContext.Student.Where(x => x.StudentNo == dto.StudentNo).FirstOrDefaultAsync();
if (student == null) if (student != null)
throw new Exception($"学号:{dto.StudentNo}的学生不存在!"); throw new Exception($"学号:{dto.StudentNo}的学生已存在!");
var device = await _sportsContext.Device.Where(x => x.Code == dto.Code).FirstOrDefaultAsync();
if (device != null)
throw new Exception($"设备编号:{dto.Code}的学生已存在!");
var entity = new S_Device() var entity = new S_Device()
{ {
@ -176,8 +182,8 @@ namespace YD_AllHeartRates.Api.Services.Impl
var student = await _sportsContext.Student.Where(x => x.StudentNo == dto.StudentNo).FirstOrDefaultAsync(); var student = await _sportsContext.Student.Where(x => x.StudentNo == dto.StudentNo).FirstOrDefaultAsync();
if (student == null) if (student != null)
throw new Exception($"学号:{dto.StudentNo}的学生存在!"); throw new Exception($"学号:{dto.StudentNo}的学生存在!");
device.StudentNo = dto.StudentNo; device.StudentNo = dto.StudentNo;
device.DeviceType = dto.DeviceType; device.DeviceType = dto.DeviceType;