Basically what I'm trying to do is make a table of all employees with their names as well. But I can't seem to find a proper way to get the name from the user, I can only get the UserName and Email.
I am looking for something that does something similair to this: @Members.GetCurrentMemberProfileModel()
but then it has to fetch the ProfileModel based on the username (or something like that). I've been looking for quite some time but can't find it.
@{
var headQuartersEmployees = (List<MembershipUser>) ViewBag.HeadQuartersEmployees;
}
@foreach (var employee in headQuartersEmployees)
{
<tr>
<td>@employee.Name <-- ??? Name is not available here ???</td>
<td>@employee.LastLoginDate</td>
<td>@employee.UserName</td>
<td>@employee.Email</td>
<td class="text-center">
<a class="btn btn-rabo-transparant" href="#" data-toggle="modal" data-target="#myModal">
<i class="fa fa-edit"></i>
</a>
<a class="btn btn-rabo-transparant remove-btn" href="#">
<i class="fa fa-remove"></i>
</a>
</td>
</tr>
}
Okay so after a few hours I found out that I could use this to fix my issue..
@ApplicationContext.Services.MemberService.GetByUsername(employee.UserName).Name
It's kinda nasty because now I need to query the db again just to get a name, while the object already has the Member
object in it, but it's inaccessible because the property is private...