示例#1
0
 public ShoppingCart()
 {
     products      = new LinkedList <UserCart>();
     usedCoupons   = new LinkedList <string>();
     paymentProxy  = new PaymentProxy();
     shippingProxy = new ShippingProxy();
 }
 public PaymentConfiguration CreateInstance(PaymentInterface paymentInterface, PaymentProvider paymentProvider, BehaviorModel behaviorModel)
 {
     if (!this.HasData)
     {
         return(null);
     }
     return(new PaymentConfiguration(this.PaymentConfigurationID, new PaymentCredentials(this.PaymentCredentialsID), paymentInterface ?? new PaymentInterface(this.PaymentInterfaceID), paymentProvider ?? new PaymentProvider(this.PaymentProviderID), behaviorModel ?? new BehaviorModel(this.BehaviorModelID), this.Name, this.Updated, this.Created));
 }
示例#3
0
        public void init()
        {
            WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();

            paymentProxy = new PaymentProxy();

            us    = userServices.getInstance();
            ss    = storeServices.getInstance();
            sellS = sellServices.getInstance();

            admin = us.startSession();
            us.register(admin, "admin", "123456");
            us.login(admin, "admin", "123456");

            admin1 = us.startSession();
            us.register(admin1, "admin1", "123456");

            zahi = us.startSession();
            us.register(zahi, "zahi", "123456");

            itamar = us.startSession();
            us.register(itamar, "itamar", "123456");
            us.login(itamar, "itamar", "123456");
            int storeId = ss.createStore("Maria&Netta Inc.", itamar);

            store = StoreManagement.getInstance().getStore(storeId);

            niv = us.startSession();
            us.register(niv, "niv", "123456");
            us.login(niv, "niv", "123456");

            ss.addStoreManager(storeId, "niv", itamar);

            int colaId = ss.addProductInStore("cola", 3.2, 10, itamar, storeId, "Drinks");

            cola = ProductManager.getInstance().getProductInStore(colaId);
            int spriteId = ss.addProductInStore("sprite", 5.2, 100, itamar, storeId, "Drinks");

            sprite = ProductManager.getInstance().getProductInStore(spriteId);
            ss.addSaleToStore(itamar, storeId, cola.getProductInStoreId(), 1, 10, DateTime.Now.AddMonths(10).ToString());
        }
示例#4
0
 public PaymentProxy()
 {
     impl = PaymentSystem.getInstance();
 }
示例#5
0
        protected override PaymentConfiguration LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             PaymentConfigurationTable.GetColumnNames("[pc]") +
                             (this.Depth > 0 ? "," + PaymentCredentialsTable.GetColumnNames("[pc_pc]") : string.Empty) +
                             (this.Depth > 0 ? "," + PaymentInterfaceTable.GetColumnNames("[pc_pi]") : string.Empty) +
                             (this.Depth > 0 ? "," + PaymentProviderTable.GetColumnNames("[pc_pp]") : string.Empty) +
                             (this.Depth > 0 ? "," + BehaviorModelTable.GetColumnNames("[pc_bm]") : string.Empty) +
                             " FROM [core].[PaymentConfiguration] AS [pc] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentCredentials] AS [pc_pc] ON [pc].[PaymentCredentialsID] = [pc_pc].[PaymentCredentialsID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentInterface] AS [pc_pi] ON [pc].[PaymentInterfaceID] = [pc_pi].[PaymentInterfaceID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentProvider] AS [pc_pp] ON [pc].[PaymentProviderID] = [pc_pp].[PaymentProviderID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[BehaviorModel] AS [pc_bm] ON [pc].[BehaviorModelID] = [pc_bm].[BehaviorModelID] ";
                }
                sqlCmdText += "WHERE [pc].[PaymentConfigurationID] = @PaymentConfigurationID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@PaymentConfigurationID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "loadinternal", "notfound"), "PaymentConfiguration could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                PaymentConfigurationTable pcTable    = new PaymentConfigurationTable(query);
                PaymentCredentialsTable   pc_pcTable = (this.Depth > 0) ? new PaymentCredentialsTable(query) : null;
                PaymentInterfaceTable     pc_piTable = (this.Depth > 0) ? new PaymentInterfaceTable(query) : null;
                PaymentProviderTable      pc_ppTable = (this.Depth > 0) ? new PaymentProviderTable(query) : null;
                BehaviorModelTable        pc_bmTable = (this.Depth > 0) ? new BehaviorModelTable(query) : null;


                PaymentCredentials   pc_pcObject = (this.Depth > 0) ? pc_pcTable.CreateInstance() : null;
                PaymentInterface     pc_piObject = (this.Depth > 0) ? pc_piTable.CreateInstance() : null;
                PaymentProvider      pc_ppObject = (this.Depth > 0) ? pc_ppTable.CreateInstance() : null;
                BehaviorModel        pc_bmObject = (this.Depth > 0) ? pc_bmTable.CreateInstance() : null;
                PaymentConfiguration pcObject    = pcTable.CreateInstance(pc_pcObject, pc_piObject, pc_ppObject, pc_bmObject);
                sqlReader.Close();

                return(pcObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "loadinternal", "exception"), "PaymentConfiguration could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "PaymentConfiguration", "Exception while loading PaymentConfiguration object from database. See inner exception for details.", ex);
            }
        }
示例#6
0
        public List <PaymentConfiguration> LoadMany(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             PaymentConfigurationTable.GetColumnNames("[pc]") +
                             (this.Depth > 0 ? "," + PaymentCredentialsTable.GetColumnNames("[pc_pc]") : string.Empty) +
                             (this.Depth > 0 ? "," + PaymentInterfaceTable.GetColumnNames("[pc_pi]") : string.Empty) +
                             (this.Depth > 0 ? "," + PaymentProviderTable.GetColumnNames("[pc_pp]") : string.Empty) +
                             (this.Depth > 0 ? "," + BehaviorModelTable.GetColumnNames("[pc_bm]") : string.Empty) +
                             " FROM [core].[PaymentConfiguration] AS [pc] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentCredentials] AS [pc_pc] ON [pc].[PaymentCredentialsID] = [pc_pc].[PaymentCredentialsID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentInterface] AS [pc_pi] ON [pc].[PaymentInterfaceID] = [pc_pi].[PaymentInterfaceID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentProvider] AS [pc_pp] ON [pc].[PaymentProviderID] = [pc_pp].[PaymentProviderID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[BehaviorModel] AS [pc_bm] ON [pc].[BehaviorModelID] = [pc_bm].[BehaviorModelID] ";
                }


                sqlCmdText = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "customloadmany", "notfound"), "PaymentConfiguration list could not be loaded using custom logic as no items were found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(new List <PaymentConfiguration>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                PaymentConfigurationTable pcTable    = new PaymentConfigurationTable(query);
                PaymentCredentialsTable   pc_pcTable = (this.Depth > 0) ? new PaymentCredentialsTable(query) : null;
                PaymentInterfaceTable     pc_piTable = (this.Depth > 0) ? new PaymentInterfaceTable(query) : null;
                PaymentProviderTable      pc_ppTable = (this.Depth > 0) ? new PaymentProviderTable(query) : null;
                BehaviorModelTable        pc_bmTable = (this.Depth > 0) ? new BehaviorModelTable(query) : null;

                List <PaymentConfiguration> result = new List <PaymentConfiguration>();
                do
                {
                    PaymentCredentials   pc_pcObject = (this.Depth > 0) ? pc_pcTable.CreateInstance() : null;
                    PaymentInterface     pc_piObject = (this.Depth > 0) ? pc_piTable.CreateInstance() : null;
                    PaymentProvider      pc_ppObject = (this.Depth > 0) ? pc_ppTable.CreateInstance() : null;
                    BehaviorModel        pc_bmObject = (this.Depth > 0) ? pc_bmTable.CreateInstance() : null;
                    PaymentConfiguration pcObject    = (this.Depth > -1) ? pcTable.CreateInstance(pc_pcObject, pc_piObject, pc_ppObject, pc_bmObject) : null;
                    result.Add(pcObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "customloadmany", "exception"), "PaymentConfiguration list could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "PaymentConfiguration", "Exception while loading (custom/many) PaymentConfiguration object from database. See inner exception for details.", ex);
            }
        }