Skip to content

Instantly share code, notes, and snippets.

@davidsonsousa
Created July 15, 2019 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsonsousa/aec0b7db495046be91ef7837c0dedfc1 to your computer and use it in GitHub Desktop.
Save davidsonsousa/aec0b7db495046be91ef7837c0dedfc1 to your computer and use it in GitHub Desktop.
public (IEnumerable<PersonTableViewModel> Data, int Count) GetPeopleForDataTable(DataParameters parameters)
{
var items = personRepository.GetPeopleReadOnly()
.Select(x => new PersonTableViewModel
{
FullName = x.FullName,
PreferredName = x.PreferredName,
Phone = x.Phone,
Email = x.Email,
Age = (DateTime.Now.Subtract(x.DateOfBirth).Days / 365).ToString(),
Status = x.Status == true ? "Active" : "Inactive"
});
if (!string.IsNullOrWhiteSpace(parameters.Search.Value))
{
PersonTableViewModel.Filter(ref items, parameters.Search.Value);
}
PersonTableViewModel.Order(ref items, parameters.Order[0].Column, parameters.Order[0].Dir);
return (items, personRepository.Count());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment