|
@@ -164,15 +164,7 @@ namespace MTWorkHR.Application.Services
|
|
|
|
|
|
// var userResp = await _userService.Create(companyUser);
|
|
|
var user = MapperObject.Mapper.Map<ApplicationUser>(companyUser);
|
|
|
- if (user.UserType == 0)
|
|
|
- {
|
|
|
- user.UserType = (int)UserTypeEnum.Business;
|
|
|
- var employeeRole = await _roleManager.FindByNameAsync("Business");
|
|
|
- if (employeeRole != null)
|
|
|
- {
|
|
|
- await _userManager.AddToRoleAsync(user, "Business");
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
var result = await _userManager.CreateAsync(user, companyUser.Password);
|
|
|
if (!result.Succeeded)
|
|
|
{
|
|
@@ -183,6 +175,15 @@ namespace MTWorkHR.Application.Services
|
|
|
}
|
|
|
throw new AppException(ExceptionEnum.RecordCreationFailed);
|
|
|
}
|
|
|
+ if (user.UserType == 0)
|
|
|
+ {
|
|
|
+ user.UserType = (int)UserTypeEnum.Business;
|
|
|
+ var employeeRole = await _roleManager.FindByNameAsync("Business");
|
|
|
+ if (employeeRole != null)
|
|
|
+ {
|
|
|
+ await _userManager.AddToRoleAsync(user, "Business");
|
|
|
+ }
|
|
|
+ }
|
|
|
return user;
|
|
|
}
|
|
|
|