/// <summary>
        /// Updates the electronics.
        /// </summary>
        /// <exception cref="Exception">Unable to fetch electronics category item.</exception>
        /// <exception cref="System.Exception">Unable to fetch electronics category item.</exception>
        public static void UpdateElectronics()
        {
            List <Category> electronicCategories = new List <Category>();

            ICategoryTable categoryTable = TablesProvider.GetCategoryTable();

            Category electronics = new Category {
                Name = "Electronics"
            };

            List <Category> elec_sub = new List <Category>()
            {
                { new Category {
                      Name = "Laptops"
                  } },
                { new Category {
                      Name = "TVs"
                  } },
                { new Category {
                      Name = "CellPhones"
                  } },
                { new Category {
                      Name = "PC Periferics"
                  } },
            };

            electronics.Subcategories = elec_sub;

            electronicCategories.Add(electronics);
            electronicCategories.AddRange(elec_sub);

            InsertCategoryList(electronicCategories);
        }
        /// <summary>
        /// Updates the home.
        /// </summary>
        /// <exception cref="Exception">Unable to fetch home category item.</exception>
        public static void UpdateHome()
        {
            ICategoryTable categoryTable = TablesProvider.GetCategoryTable();

            Category home = new Category {
                Name = "Home"
            };

            List <Category> home_sub = new List <Category>()
            {
                { new Category {
                      Name = "Chairs"
                  } },
                { new Category {
                      Name = "Tables"
                  } },
                { new Category {
                      Name = "Bolts"
                  } },
            };

            home.Subcategories = home_sub;

            List <Category> homeCategories = new List <Category>();

            homeCategories.Add(home);
            homeCategories.AddRange(home_sub);

            InsertCategoryList(homeCategories);
        }
        /// <summary>
        /// Inserts the category list.
        /// </summary>
        /// <param name="list">The list.</param>
        public static void InsertCategoryList(List <Category> list)
        {
            ICategoryTable categoryTable = TablesProvider.GetCategoryTable();

            foreach (Category category in list)
            {
                try
                {
                    categoryTable.InsertCategory(category);
                }
                catch (Exception)
                {
                }
            }

            foreach (Category category in list)
            {
                try
                {
                    Category fetched_with_id     = categoryTable.FetchCategoryByName(category.Name);
                    Category fetched_sub_with_id = categoryTable.FetchCategoryByName(category.Name);
                    foreach (Category sub_category in category.Subcategories)
                    {
                        categoryTable.InsertSubCategory(fetched_with_id.IdCategory, fetched_sub_with_id.IdCategory);
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the available categories.
        /// </summary>
        /// <returns>All available categories.</returns>
        public List <Category> GetAvailableCategories()
        {
            ICategoryTable  categoryTable = this.tablesProvider.GetCategoryTable();
            List <Category> categories    = categoryTable.FetchAllCategories();

            return(categories);
        }
Exemplo n.º 5
0
        public void UpdateHome_ShouldChangeTheListSize()
        {
            ICategoryTable categoryTable = tables.GetCategoryTable();
            int            actual_size   = categoryTable.FetchAllCategories().Count;

            CategoriesUpdater.TablesProvider = tables;
            CategoriesUpdater.UpdateHome();

            int new_size = categoryTable.FetchAllCategories().Count;

            Assert.NotEqual(actual_size, new_size);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Prevents a default instance of the <see cref="DomainDataStorage"/> class from being created.
        /// </summary>
        private DomainDataStorage()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString;

            this.databaseConneection = new MySqlConnection(connectionString);

            this.auctionTable       = this.databaseConneection.As <IAuctionTable>();
            this.bidTable           = this.databaseConneection.As <IBidTable>();
            this.categoryTable      = this.databaseConneection.As <ICategoryTable>();
            this.currencyTable      = this.databaseConneection.As <ICurrencyTable>();
            this.personBidderTable  = this.databaseConneection.As <IPersonBidderTable>();
            this.personMarkTable    = this.databaseConneection.As <IPersonMarkTable>();
            this.personOfferorTable = this.databaseConneection.As <IPersonOfferorTable>();
            this.personTable        = this.databaseConneection.As <IPersonTable>();
            this.productTable       = this.databaseConneection.As <IProductTable>();
        }
Exemplo n.º 7
0
 public CategoryDatabaseValidateService(ICategoryTable categoryTable,
                                        IGenderDatabaseValidateService genderDatabaseValidateService)
     : base(categoryTable)
 {
     _genderDatabaseValidateService = genderDatabaseValidateService;
 }
 /// <summary>
 /// База данных
 /// </summary>
 private static Mock <IBoutiqueDatabase> GetDatabase(IGenderTable genderTable, ICategoryTable categoryTable,
                                                     IClothesTypeTable clothesTypeTable) =>
 new Mock <IBoutiqueDatabase>().
 Void(mock => mock.Setup(database => database.GendersTable).Returns(genderTable)).
 Void(mock => mock.Setup(database => database.CategoryTable).Returns(categoryTable)).
 Void(mock => mock.Setup(database => database.ClotheTypeTable).Returns(clothesTypeTable));