diff --git a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Providers/UserAccessProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Providers/UserAccessProvider.cs index 5fbfe75..740e410 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Providers/UserAccessProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Providers/UserAccessProvider.cs @@ -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(user);