pointonsoftware / pscore

C++ library for building your business software
GNU Affero General Public License v3.0
1 stars 2 forks source link

Create a Core controller base class #177

Closed gbenziv closed 3 years ago

gbenziv commented 3 years ago

This base class should contain all the generic member data and functions of a controller.

Notable things to house in the base class:

typedef std::map<std::string, std::string> ValidationErrors;
std::shared_ptr<D> mDataProvider;
std::shared_ptr<V> mView;
void dumpValidationResult(const ValidationErrors& validationErrors) const;
void save(const std::string& id) {
    // Decide if it's a create or update request
    if (isExists(customer.ID())) {
        update(customer);
    } else {
        create(customer);
    }
}

Move get, list, update, create and remove

Cache operations
std::vector<E> mCachedList;
bool isExists(const std::string& barcode);
std::vector<entity::Product>::iterator find(const std::string& barcode);