Comments (2)
I'm trying to understand your code here, so let me tell you how i've interpreted the above to arrive at my recommendation...
- The 'bookapply' method does not look like a Domain class method. Since it is static and Domain class methods are instance level methods working on the Records property in conjunction with parameters passed in and i don't see this either.
- Normally the Controller calls a Service class method, so is this what 'bookapply' method is?
- So if the 'bookappy' method is really a Service class method, what is the purpose of it in a business sense? Is it to take a list of Email addresses and query for BookStore__c records?
If so, you should have three classes, controller > service class > selector class. In this case you don't strictly need a Domain class at this stage, though see my note below.
public class BookStoreController {
public PageReference bookApply()
{
List<String> emails = null; // < Get list of Emails from view state?
try {
BookStoreService.bookApply(emails);
} catch (Exception e) {
ApexPages.addMessage(e):
}
}
}
public class BookStoreService {
public static void bookApply(Set<String> emailAddresses) {
List<BookStore__c> bookStores =
new BookStoresSelector().selectByEmail(emailAddresses);
// Do something with the bookStores?
// ...
}
}
public class BookStoresSelector extends fflib_SObjectSelector {
// See documentation for full example of methods to implement
// ....
public List<BookStore__c> selectByEmail(Set<String> emails) {
assertIsAccessible();
return Database.query(
String.format('SELECT {0} FROM {1} WHERE Email__c in :emails ORDER BY {2}',
new List<String>{getFieldListString(),getSObjectName(),getOrderBy()}));
}
}
You may wish to create a BookStores Domain class (especially if you have an Apex Trigger on this object). In which case you could encapsulate the behaviour of the bookApply logic in such a class and then call the BookStores Domain class from the Service method above. So the flow would be BookStoreController.bookApply > BookStoreService.bookApply > BookStoresSelector.selectByEmail > BookStores.bookApply
from fflib-apex-common.
Let me know if you want to continue to discuss, hopefully this moved things along for you! 👍
from fflib-apex-common.
Related Issues (20)
- Unable to Deploy - Unhandled Exception : java.lang.RuntimeException HOT 1
- Unit test failure in multi-currency org HOT 4
- Deploy button doesn't deploy because there are test failures HOT 1
- Expected a QueryException due to read only user not having access to Opportunity HOT 7
- Switch to Inherited Sharing on SObjectDescribe and SObjectSelector HOT 2
- With latest fflib, do TriggerHandlers become service class consumers? If so what happens to UoW? HOT 6
- Selected tests in fflib_SObjectSelectorTest fail in an org with encryption enabled on Account.Name HOT 2
- Selector Mocks to Include SOQL Query Retrieve Check HOT 1
- fflib_SObjectUnitOfWork doCommitWork executes all dml for all registered types even if there are no changes
- Update README as session recordings are not available HOT 2
- fflib_SObjectDescribe.cls fails to resolve cross-object field paths for Person Accounts
- Aggregate SOQL support. HOT 2
- Disable Savepoint in tests HOT 4
- Inconsistent Code Coverage and Test Failures in fflib-apex-common HOT 1
- fflib_SObjectSelector and fflib_SObjectUnitOfWork have insufficient test code coverage. HOT 2
- Add queryWithBinds to Selector layer HOT 2
- Unit test failing fflib_SecurityUtilsTest & sysadmin_objectAndField_access HOT 8
- Coverage of UnitOfWork class HOT 1
- Versioning HOT 1
- fflib_SObjectSelectorTest failure with Lookup relationship and Person Type Accounts HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fflib-apex-common.