This class realizes the main target of the overall system: let a user to buy products by placing an order; analyzing the ER model, it’s possible to see that an order is a master-detail structure, in which the master is represented by this class and contains information about the owner of the order, the date and the overall total; the detail part is made up of the list of chosen products (relation 'madeup' of ER model). More...
#include <Order.h>
Public Member Functions | |
Order () | |
Default constructor. | |
Order (Row &aRow) | |
Construct an instance of Order with data fetched from the database. | |
~Order () | |
Default destructor. | |
string | primaryKey () |
Returns the primary for entity "orders" (KEY_ORD_OID). | |
map< int, int > & | products () |
Returns the list of products (and requested quantity) of an order. | |
Static Public Member Functions | |
static Order * | create (int anUid, Basket &bsk) |
Create a new order. | |
static vector< Order * > & | ordersForUser (User &pp) |
Return the list of all orders of a given user. | |
Private Attributes | |
User * | _user |
Friends | |
ostream & | operator<< (ostream &, Order &) |
This class realizes the main target of the overall system: let a user to buy products by placing an order; analyzing the ER model, it’s possible to see that an order is a master-detail structure, in which the master is represented by this class and contains information about the owner of the order, the date and the overall total; the detail part is made up of the list of chosen products (relation 'madeup' of ER model).
Order::Order | ( | ) |
Order::Order | ( | Row & | aRow | ) |
Construct an instance of Order with data fetched from the database.
[in] | aRow | An instance of mysqlpp::Row with data |
References _user, ManagedObject::intForKey(), KEY_ORD_UID, LOG_CTOR, and User::userByID().
Order::~Order | ( | ) |
Create a new order.
[in] | anUid | ID of user that places the order |
[in] | bsk | User basket containing products |
References Database::getConnection(), ManagedObject::getLastInsertID(), Singleton< Database >::instance(), KEY_ORD_DATE, KEY_ORD_OID, KEY_ORD_TOTAL, KEY_ORD_UID, LOG, Order(), ManagedObject::setFloatForKey(), ManagedObject::setIntForKey(), ManagedObject::setValueForKey(), ManagedObject::store(), and Basket::total().
Referenced by NormalUser::placeOrder().
Return the list of all orders of a given user.
[in] | pp | An instance of User |
References Database::getConnection(), Singleton< Database >::instance(), Order(), and User::uniqueID().
Referenced by UserMenu::showUserProfile().
string Order::primaryKey | ( | ) | [virtual] |
Returns the primary for entity "orders" (KEY_ORD_OID).
Implements ManagedObject.
References KEY_ORD_OID.
map< int, int > & Order::products | ( | ) |
Returns the list of products (and requested quantity) of an order.
References Database::getConnection(), Singleton< Database >::instance(), KEY_ORD_OID, and ManagedObject::valueForKey().
Referenced by UserMenu::showUserProfile().
ostream& operator<< | ( | ostream & | aStream, | |
Order & | o | |||
) | [friend] |
User* Order::_user [private] |
Referenced by operator<<(), Order(), and ~Order().