Hello everyone I have call this function by ajax call
public JsonResult OnGetUserDetails(string User)
{
var currentDate = DateTime.UtcNow.Date;
var usersDetails = _con.Users
.Join(
_con.Claims.Where(c => c.Type == "Status" && c.Value == "active"),
u => u.Id,
c1 => c1.UserId,
(u, c1) => new { User = u, Claim1 = c1 }
)
.Join(
_con.Claims.Where(c => c.Type == "End"),
uc1 => uc1.User.Id,
c2 => c2.UserId,
(uc1, c2) => new { Claim = uc1, Claim2 = c2 }
)
.AsEnumerable()
.Where(ucc => DateTime.Parse(ucc.Claim2.ClaimValue).Date > currentDate)
.Select(ucc => new UserDetailsViewModel
{
UserEmail = ucc.Claim.User.Email,
Name = ucc.Claim.User.FirstName
}).ToList();
return new JsonResult(usersDetails);
}
It's get successfully data from data base But I have faced a issue , how to return this razor view pages with foreach loop.
This is view code
@model List<App.Pages.Search.Partial.UserListForEmailSendModel>
<table>
<thead>
<tr>
<th>User Email</th>
<th>Name</th>
</tr>
</thead>
<tbody>
@foreach (var userDetails in )
{
<tr>
<td>@userDetails.UserEmail</td>
<td>@userDetails.Name</td>
</tr>
}
</tbody>
</table>