Merged PR 91: added additional fields in user method

added additional fields in user method
This commit is contained in:
Uppu, Vijay 2023-12-14 17:55:33 +00:00
commit dd5351665e

View File

@ -88,14 +88,28 @@ namespace DamageAssesment.Api.UsersAccess.Providers
{
var employee = employees.SingleOrDefault(a=>a.Id==user.EmployeeId);
var role = roles.SingleOrDefault(s => s.Id == user.RoleId);
string FirstName = null, LastName = null, EmployeeName = null;
if (employee != null)
{
string[] names = employee.Name.Split(' ');
EmployeeName = employee.Name;
FirstName = names[0];
LastName = EmployeeName.Replace(FirstName+" ","");
}
userslist.Add(new
{
Id = user.Id,
EmployeeId = user.EmployeeId,
EmployeeCode = user.EmployeeCode,
EmployeeName = (employee != null) ? employee.Name : null,
FirstName = FirstName,
LastName = LastName,
EmployeeName = EmployeeName,
RoleId = user.RoleId,
RoleName = (role != null) ? role.Name : null
RoleName = (role != null) ? role.Name : null,
IsActive = user.IsActive,
CreatedDate = user.CreateDate,
UpdatedDate = user.UpdateDate
});
}
logger?.LogInformation($"{users.Count} Items(s) found");
@ -121,14 +135,27 @@ namespace DamageAssesment.Api.UsersAccess.Providers
{
var employee = await employeeServiceProvider.getEmployeeAsync(user.EmployeeId,GetToken());
var role = await userAccessDbContext.Roles.SingleOrDefaultAsync(s => s.Id == user.RoleId);
string FirstName = null, LastName = null, EmployeeName = null;
if(employee != null)
{
string[] names = employee.Name.Split(' ');
EmployeeName = employee.Name;
FirstName = names[0];
LastName = EmployeeName.Replace(FirstName + " ", "");
}
var data = new
{
Id = user.Id,
EmployeeId = user.EmployeeId,
EmployeeCode=user.EmployeeCode,
EmployeeName = (employee != null) ? employee.Name : null,
FirstName= FirstName,
LastName= LastName,
EmployeeName = EmployeeName,
RoleId = user.RoleId,
RoleName = (role!=null)?role.Name:null
RoleName = (role!=null)?role.Name:null,
IsActive=user.IsActive,
CreatedDate=user.CreateDate,
UpdatedDate=user.UpdateDate
};
logger?.LogInformation($"User Id: {Id} found");
var result = mapper.Map<Db.User, Models.User>(user);