public IPagedQueryResult <IEnumerable <EmailTemplateModel> > GetAll(EmailTemplateFilter filter) { var query = _context.EmailTemplates .Filter(x => x.Name.Contains(filter.Search) || x.Body.Contains(filter.Search), filter.Search) .Sort(x => x.Id, filter.OrderBy) .Sort(x => x.Name, filter.OrderBy) .Sort(x => x.LastModifierUserId, filter.OrderBy) .Sort(x => x.LastModificationTime, filter.OrderBy); var list = query .GetPaged(filter.PageIndex, filter.PageSize) .AsEnumerable().Select(_mapper.Map <EmailTemplateModel>) .ToList(); //update last modifier name foreach (EmailTemplateModel item in list.Where(m => m.LastModifierUserId != null && m.LastModifierUserId > 0)) { item.LastModifierUser = _context.Users.First(m => m.Id == item.LastModifierUserId).FullName; } return(list.ToPagedQueryResult(filter, query.AsNoTracking().Count())); }
public IActionResult GetAll([FromQuery] EmailTemplateFilter request) { return(Ok(_emailTemplateQuery.GetAll(request))); }