#include "commodityservice.h" #include "commodity-odb.hxx" CommodityService::CommodityService() { } QList > CommodityService::shopItems() { QList > ret; foreach (QSharedPointer data, all()) { ret.append(qSharedPointerDynamicCast(data)); } return ret; } void CommodityService::addedToVoucher(int itemId, int countAdded) { QSharedPointer commodity = loadById(itemId); if (!commodity.isNull()) { commodity->setCount(commodity->count() - countAdded); } update(commodity); } ShopItemPtr CommodityService::shopItem(int itemId) { CommodityDataPtr item = this->loadById(itemId); return qSharedPointerDynamicCast(item); } ISeller *CommodityService::seller() { return NULL; }