员工工号重复BUG修复

parent a0a53097
...@@ -336,12 +336,9 @@ public ApiResponse UpdatePerson(PerEmployeeResponse request) ...@@ -336,12 +336,9 @@ public ApiResponse UpdatePerson(PerEmployeeResponse request)
throw new PerformanceException($"“关键信息缺失”请补全!"); throw new PerformanceException($"“关键信息缺失”请补全!");
} }
var employees = peremployeeRepository.GetEntities(t => t.AllotId == request.AllotId && t.Id == request.Id); var employees = peremployeeRepository.GetEntities(t => t.AllotId == request.AllotId && t.Id != request.Id && t.PersonnelNumber == request.PersonnelNumber);
if (employees == null) if (employees != null && employees.Count > 0)
throw new PerformanceException($"员工工号为“{request.PersonnelNumber}”不存在,请重新添加!"); throw new PerformanceException($"员工工号为“{request.PersonnelNumber}”已存在,请勿重复添加!");
if (employees.Count() > 1)
throw new PerformanceException($"工号为“{request.PersonnelNumber}”存在多条数据,请删除多余数据!");
var unittype = UnitTypeUtil.GetUnitTypeFromEnum().Select(t => t.Description).ToList(); var unittype = UnitTypeUtil.GetUnitTypeFromEnum().Select(t => t.Description).ToList();
unittype.AddRange(EnumHelper.GetItems<AccountUnitType>().Select(t => t.Description)); unittype.AddRange(EnumHelper.GetItems<AccountUnitType>().Select(t => t.Description));
...@@ -349,7 +346,10 @@ public ApiResponse UpdatePerson(PerEmployeeResponse request) ...@@ -349,7 +346,10 @@ public ApiResponse UpdatePerson(PerEmployeeResponse request)
if (!unittype.Contains(request.UnitType)) if (!unittype.Contains(request.UnitType))
throw new PerformanceException($"核算组别不符合规范!"); throw new PerformanceException($"核算组别不符合规范!");
var employee = employees.First(); var employee = peremployeeRepository.GetEntity(t => t.AllotId == request.AllotId && t.Id == request.Id);
if (employee == null)
throw new PerformanceException($"当前要修改的员工信息不存在,请检查后重试!");
//_mapper.Map(request, employee, typeof(per_employee), typeof(per_employee)); //_mapper.Map(request, employee, typeof(per_employee), typeof(per_employee));
employee.AccountingUnit = request.AccountingUnit; employee.AccountingUnit = request.AccountingUnit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment