Пример #1
0
 public Subscription(Customer customer)
 {
     this._id = Guid.NewGuid ();
     this._createtimestamp = SNDK.Date.CurrentDateTimeToTimestamp ();
     this._updatetimestamp = SNDK.Date.CurrentDateTimeToTimestamp ();
     this._type = qnaxLib.Enums.SubscriptionType.Monthly;
     this._customerid = customer.Id;
     this._title = "Subscription";
     this._items = new List<SubscriptionItem> ();
     //			this._nextbilling = SNDK.Date.DateTimeToTimestamp (DateTime.Today.AddDays (1));
     //			this._nextbilling = SNDK.Date.DateTimeToTimestamp (DateTime.Today);
     this._nextbilling = SNDK.Date.DateTimeToTimestamp (new DateTime (2012, 9, 13));
     Console.WriteLine (SNDK.Date.TimestampToDateTime (this._nextbilling));
 }
Пример #2
0
        /// <summary>
        /// Load a <see cref="qnaxLib.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 List<Subscription> List(Customer customer)
 {
     return List (customer.Id);
 }
Пример #4
0
        /// <summary>
        ///  Turns a <see cref="System.Xml.XmlDocument"/> into a <see cref="qnaxLib.Customer"/>.
        /// </summary>			
        public static Customer FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);

            Customer result;

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

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

            return result;
        }