public FindLocationsResponse Find(FindLocationsRequest request) { try { _locationQuery.Init(); _locationQuery.WithOnlyActivated(true); _locationQuery.WithName(request.Name); _locationQuery.WithType(request.Type.ConvertToEnum <ELocationType>()); _locationQuery.WithUser(request.UserId); _locationQuery.Sort(request.Sort, request.SortBy); var totalRecords = _locationQuery.TotalRecords(); _locationQuery.Paginate(request.ItemsToShow, request.Page); var locations = _locationQuery.Execute(); return(new FindLocationsResponse { Locations = TypeAdapter.Adapt <List <LocationResponse> >(locations), TotalRecords = totalRecords }); } catch (DataAccessException) { throw new ApplicationException(); } }