示例#1
0
        //Assuming at least one ShippingMethod has been created using the Orders UI
        public Guid GetShippingMethodID()
        {
            Guid    shippingMethodId = Guid.Empty;
            Boolean shipMethodFound  = false;

            //Get all PaymentMethods in default language - Hopefully there is one of each type
            DataSet         shipMethods = orderCtx.GetShippingMethods();
            DataTableReader reader      = shipMethods.CreateDataReader();

            IEnumerator readerEnum = reader.GetEnumerator();

            while (readerEnum.MoveNext() && !shipMethodFound)
            {
                DbDataRecord rec = (DbDataRecord)readerEnum.Current;
                shippingMethodId = rec.GetGuid(rec.GetOrdinal("ShippingMethodId"));
                shipMethodFound  = true;
            }

            if (Guid.Empty == shippingMethodId)
            {
                throw new ApplicationException("This demo requires at least one ShippingMethod to be defined!");
            }

            return(shippingMethodId);
        }
示例#2
0
        //Assuming at least one CreditCard PaymentMethod has been created using the Orders UI
        public Guid GetPaymentMethodID()
        {
            Guid    creditCardPaymentMethodId = Guid.Empty;
            Boolean ccPmtMethodFound          = false;

            //Get all PaymentMethods
            DataSet         pmtMethods = orderCtx.GetPaymentMethods();
            DataTableReader reader     = pmtMethods.CreateDataReader();

            IEnumerator readerEnum = reader.GetEnumerator();

            while (readerEnum.MoveNext() && !ccPmtMethodFound)
            {
                DbDataRecord rec = (DbDataRecord)readerEnum.Current;
                switch (rec.GetInt32(rec.GetOrdinal("PaymentType")))
                {
                case (int)PaymentMethodTypes.CreditCard:
                    creditCardPaymentMethodId = rec.GetGuid(rec.GetOrdinal("PaymentMethodId"));
                    ccPmtMethodFound          = true;
                    break;
                }
            }

            if (Guid.Empty == creditCardPaymentMethodId)
            {
                throw new ApplicationException("This demo requires at least one CreditCard type of PaymentMethod to be defined!");
            }

            return(creditCardPaymentMethodId);
        }
        public static Guid GetGuid(this DbDataRecord dr, string columnName)
        {
            Check.ArgNotNull(dr, nameof(dr));
            int ordinal = dr.GetOrdinal(columnName);

            return(dr.GetGuid(ordinal));
        }