Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="qnax.Subscription"/> class.
 /// </summary>
 public Subscription(Customer Customer)
 {
     this._id = Guid.NewGuid ();
     this._createtimestamp = SNDK.Date.CurrentDateTimeToTimestamp ();
     this._updatetimestamp = SNDK.Date.CurrentDateTimeToTimestamp ();
     this._customerid = Customer.Id;
 }
Пример #2
0
        /// <summary>
        /// Load a <see cref="qnax.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"
                );

            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"));

                    success = true;
                }
            }

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

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

            return result;
        }
Пример #3
0
        public static Customer FromItem(Hashtable Item)
        {
            Customer result = null;

            if (Item.ContainsKey ("id"))
            {
                try
                {
                    result = Customer.Load (new Guid ((string)Item["id"]));
                }
                catch
                {
                    result = new Customer ();
                    result._id = new Guid ((string)Item["id"]);
                }
            }

            if (result == null)
            {
                result = new Customer ();
            }

            if (Item.ContainsKey ("name"))
            {
                result.Name = (string)Item["name"];
            }

            return result;
        }