diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs index 8c452b890..4f4a09421 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs @@ -79,7 +79,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk(_localizer["Doctor_DupEmail"], new DoctorBasicInfoCommand()); } - doctor.Code = (await _doctorRepository.MaxAsync(t => t.Code)) + 1; + doctor.Code = await _doctorRepository.Select(t => t.Code).DefaultIfEmpty().MaxAsync() + 1; doctor.ReviewerCode = AppSettings.GetCodeStr(doctor.Code, nameof(Doctor)); diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index 4a78b453a..9d77f48ed 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -67,7 +67,7 @@ namespace IRaCIS.Application.Services siteCommand.Code = await _siteRepository.Select(t => t.Code).DefaultIfEmpty().MaxAsync() + 1; - siteCommand.SiteCode = AppSettings.GetCodeStr(siteCommand.Code, nameof(User)); + siteCommand.SiteCode = AppSettings.GetCodeStr(siteCommand.Code, nameof(Site)); } var site = await _siteRepository.InsertOrUpdateAsync(siteCommand, true, exp);