Пример #1
0
        /// <summary>
        /// Load a <see cref="CDRLib.Customer"/> instance from database using a <see cref="System.Guid"/> identifier.
        /// </summary>
        public static Customer Load(Guid Id)
        {
            bool success = false;
            Customer result = new Customer ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns (
                "id",
                "createtimestamp",
                "updatetimestamp",
                "name",
                "subscriptionids"
                );

            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._name = query.GetString (qb.ColumnPos ("name"));
                    result._subscriptionidsasstring = query.GetString (qb.ColumnPos ("subscriptionids"));

                    success = true;
                }
            }

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

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

            return result;
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CDRLib.Subscription"/> class.
 /// </summary>
 public Subscription(Customer Customer)
 {
     this._id = Guid.NewGuid ();
     this._createtimestamp = Toolbox.Date.CurrentDateTimeToTimestamp ();
     this._updatetimestamp = Toolbox.Date.CurrentDateTimeToTimestamp ();
 }