added additional fields in user method

This commit is contained in:
Vijay Uppu 2023-12-14 10:21:14 -05:00
parent c014739fc0
commit ff4e8de3f3

View File

@ -88,14 +88,28 @@ namespace DamageAssesment.Api.UsersAccess.Providers
{ {
var employee = employees.SingleOrDefault(a=>a.Id==user.EmployeeId); var employee = employees.SingleOrDefault(a=>a.Id==user.EmployeeId);
var role = roles.SingleOrDefault(s => s.Id == user.RoleId); 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 userslist.Add(new
{ {
Id = user.Id, Id = user.Id,
EmployeeId = user.EmployeeId, EmployeeId = user.EmployeeId,
EmployeeCode = user.EmployeeCode, EmployeeCode = user.EmployeeCode,
EmployeeName = (employee != null) ? employee.Name : null, FirstName = FirstName,
LastName = LastName,
EmployeeName = EmployeeName,
RoleId = user.RoleId, 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"); 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 employee = await employeeServiceProvider.getEmployeeAsync(user.EmployeeId,GetToken());
var role = await userAccessDbContext.Roles.SingleOrDefaultAsync(s => s.Id == user.RoleId); 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 var data = new
{ {
Id = user.Id, Id = user.Id,
EmployeeId = user.EmployeeId, EmployeeId = user.EmployeeId,
EmployeeCode=user.EmployeeCode, EmployeeCode=user.EmployeeCode,
EmployeeName = (employee != null) ? employee.Name : null, FirstName= FirstName,
LastName= LastName,
EmployeeName = EmployeeName,
RoleId = user.RoleId, 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"); logger?.LogInformation($"User Id: {Id} found");
var result = mapper.Map<Db.User, Models.User>(user); var result = mapper.Map<Db.User, Models.User>(user);