diff --git a/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs b/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs index 2c43c8a87..2340b302f 100644 --- a/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs +++ b/IRaCIS.Core.Application/BusinessFilter/_Config/_AppSettings.cs @@ -140,7 +140,7 @@ public static class AppSettings case nameof(Doctor): return IRaCISBasicConfig.DoctorCodePrefix + codeInt.ToString("D4"); - case nameof(UserRole): + case nameof(IdentityUser): return IRaCISBasicConfig.UserCodePrefix + codeInt.ToString("D4"); case nameof(QCChallenge): diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 37d34c154..ecbc4d59a 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -648,7 +648,6 @@ namespace IRaCIS.Core.Application.Service if (user == null) return Null404NotFound(user); - var existDBRoleList = user.UserRoleList; if (user.Status != model.Status) { @@ -670,24 +669,25 @@ namespace IRaCIS.Core.Application.Service foreach (var role in model.UserRoleList) { - var find = existDBRoleList.FirstOrDefault(t => t.UserTypeEnum == role.UserTypeEnum && t.UserTypeId == role.UserTypeId); + var find = user.UserRoleList.FirstOrDefault(t => t.UserTypeEnum == role.UserTypeEnum && t.UserTypeId == role.UserTypeId); - if (find != null) + if (find != null ) { - find.IsUserRoleDisabled = false; + find.IsUserRoleDisabled = role.IsUserRoleDisabled; } else { var addRole = _mapper.Map(model); + addRole.Id = NewId.NextSequentialGuid(); + addRole.IdentityUserId = user.Id; addRole.UserTypeEnum = role.UserTypeEnum; addRole.UserTypeId = role.UserTypeId; - existDBRoleList.Add(addRole); + user.UserRoleList.Add(addRole); } } - user.UserRoleList = existDBRoleList; var success = await _userRoleRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs index 3bd92ef01..d40cb6668 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -17,7 +17,11 @@ namespace IRaCIS.Core.Application.Service CreateMap().ForMember(d => d.UserCode, x => x.Ignore()); - CreateMap().ForMember(d => d.UserCode, x => x.Ignore()); + + CreateMap() + .ForMember(d => d.UserCode, x => x.Ignore()) + .ForMember(d => d.UserRoleList, x => x.Ignore()); + CreateMap().ReverseMap() .ForMember(t => t.UserTypeMenuList, u => u.MapFrom(c => c.MenuIds)) .ForMember(t => t.UserTypeGroupList, u => u.MapFrom(c => c.UserTypeGroupIdList));