You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
prodejna/commodity/commodityservice.cpp

48 lines
935 B
C++

#include "commodityservice.h"
#include "commodity-odb.hxx"
CommodityService::CommodityService()
{
}
QList<QSharedPointer<ShopItem> > CommodityService::shopItems()
{
QList<QSharedPointer<ShopItem> > ret;
foreach (QSharedPointer<CommodityData> data, all()) {
ret.append(qSharedPointerDynamicCast<ShopItem, CommodityData>(data));
}
return ret;
}
void CommodityService::addedToVoucher(int itemId, int countAdded)
{
QSharedPointer<CommodityData> 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<ShopItem, CommodityData>(item);
}
ISeller *CommodityService::seller()
{
return NULL;
}
QString CommodityService::defaultSort()
{
return "name";
}