public PagedResult <ClientesViewModel> GetAll(int page = 1, int pageSize = 30, string textSearch = "", string orderBy = "Id", bool ascending = true) { var loggedClient = GetClienteByIdUsuario(); var result = new PagedResult <ClientesViewModel>(); IEnumerable <Clientes> data = null; if (loggedClient != null) { var models = _rep.GetAll(page, pageSize, textSearch, orderBy, ascending); data = models.Where(t => t.Id == loggedClient.Id); } else { data = _rep.GetAll(page, pageSize, textSearch, orderBy, ascending); } result.PageNumber = page; result.PageSize = pageSize; result.Itens = Mapper.Map <IEnumerable <ClientesViewModel> >(data); result.TotalResults = _rep.Count(textSearch); return(result); }