예제 #1
0
 public void AddItem(Product Product)
 {
     SubscriptionItem item = new SubscriptionItem (this, Product);
     this._items.Add (item);
 }
예제 #2
0
        public static SubscriptionItem Load(Guid Id)
        {
            bool success = false;
            SubscriptionItem result = new SubscriptionItem ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns
                (
                    "id",
                    "createtimestamp",
                    "updatetimestamp",
                    "subscriptionid",
                    "productid",
                    "text",
                    "price"
                );

            qb.AddWhere ("id", "=", Id);

            Query query = Runtime.DBConnection.Query (qb.QueryString);

            if (query.Success)
            {
                if (query.NextRow ())
                {
                    result._id = query.GetGuid (qb.ColumnPos ("id"));
                    result._createtimestamp = query.GetInt (qb.ColumnPos ("createtimestamp"));
                    result._updatetimestamp = query.GetInt (qb.ColumnPos ("updatetimestamp"));
                    result._subscriptionid = query.GetGuid (qb.ColumnPos ("subscriptionid"));
                    result._productid = query.GetGuid (qb.ColumnPos ("productid"));
                    result._text = query.GetString (qb.ColumnPos ("text"));
                    result._price = query.GetDecimal (qb.ColumnPos ("price"));

                    success = true;
                }
            }

            query.Dispose ();
            query = null;
            qb = null;

            if (!success)
            {
                throw new Exception (string.Format (Strings.Exception.SubscriptionItemLoad, Id));
            }

            return result;
        }