예제 #1
0
        /// <summary>
        /// 删除属性值
        /// </summary>
        /// <param name="id"></param>
        public virtual async Task DeleteValueAsync(long id)
        {
            var attribute = await ProductAttributeValueRepository.FirstOrDefaultAsync(id);

            if (attribute != null)
            {
                await ProductAttributeValueRepository.DeleteAsync(attribute);
            }
        }
예제 #2
0
 /// <summary>
 /// 删除属性值
 /// </summary>
 /// <param name="attribute"></param>
 /// <returns></returns>
 public virtual async Task DeleteValueAsync(ProductAttributeValue attribute)
 {
     await ProductAttributeValueRepository.DeleteAsync(attribute);
 }
예제 #3
0
 /// <summary>
 /// 根据id获取属性值
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public virtual async Task <ProductAttributeValue> GetValueByIdAsync(long id)
 {
     return(await ProductAttributeValueRepository.GetAsync(id));
 }
예제 #4
0
 /// <summary>
 /// 添加属性值
 /// </summary>
 /// <param name="attribute"></param>
 public virtual async Task CreateValueAsync(ProductAttributeValue attribute)
 {
     await ProductAttributeValueRepository.InsertAsync(attribute);
 }
예제 #5
0
 /// <summary>
 /// 根据id查找属性值
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public virtual async Task <ProductAttributeValue> FindValueByIdAsync(long id)
 {
     return(await ProductAttributeValueRepository.FirstOrDefaultAsync(id));
 }
예제 #6
0
 /// <summary>
 /// 根据id获取属性值
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public virtual ProductAttributeValue GetValueById(long id)
 {
     return(ProductAttributeValueRepository.Get(id));
 }
예제 #7
0
 /// <summary>
 /// 根据id查找属性值
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public virtual ProductAttributeValue FindValueById(long id)
 {
     return(ProductAttributeValueRepository.FirstOrDefault(id));
 }
예제 #8
0
 /// <summary>
 /// 根据名称查找属性值
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public virtual async Task <ProductAttributeValue> FindValueByNameAsync(string name)
 {
     return(await ProductAttributeValueRepository.FirstOrDefaultAsync(x => x.Name == name));
 }
예제 #9
0
 /// <summary>
 /// 根据商品id,属性Id和预设值id查找属性值
 /// </summary>
 /// <param name="productId"></param>
 /// <param name="attributeId"></param>
 /// <param name="pValueId"></param>
 /// <returns></returns>
 public async Task <ProductAttributeValue> FindValueAsync(long productId, long attributeId, long pValueId)
 {
     return(await ProductAttributeValueRepository.GetAllIncluding(x => x.ProductAttributeMapping)
            .FirstOrDefaultAsync(x => x.ProductId == productId && x.ProductAttributeMapping.ProductAttributeId == attributeId &&
                                 x.PredefinedProductAttributeValueId == pValueId));
 }
예제 #10
0
 /// <summary>
 /// 根据属性Id和预设值id查找属性值
 /// </summary>
 /// <param name="attributeId"></param>
 /// <param name="pValueId"></param>
 /// <returns></returns>
 public async Task <ProductAttributeValue> FindValueByAttributeIdAndPredefinedValueIdAsync(long attributeId, long pValueId)
 {
     return(await ProductAttributeValueRepository
            .FirstOrDefaultAsync(x => x.ProductAttributeMapping.ProductAttributeId == attributeId &&
                                 x.PredefinedProductAttributeValueId == pValueId));
 }
예제 #11
0
        public ECommerceUnitTests()
        {
            int.TryParse(ConfigurationManager.AppSettings["TwoFactorAuthTimeSpan"], out _twoFactorAuthTimeSpan);
            int.TryParse(ConfigurationManager.AppSettings["TwoFactorTimeOut"], out _twoFactorTimeOut);
            bool.TryParse(ConfigurationManager.AppSettings["TwoFactorEnabled"], out _twoFactorEnabled);
            _twoFactorAuthCookie    = ConfigurationManager.AppSettings["TwoFactorAuthCookie"];
            _twoFactorAuthSmtpHost  = ConfigurationManager.AppSettings["TwoFactorAuthSmtpHost"];
            _twoFactorAuthFromEmail = ConfigurationManager.AppSettings["TwoFactorAuthFromEmail"];
            _twoFactorAuthFromPhone = ConfigurationManager.AppSettings["TwoFactorAuthFromPhone"];
            _emailPassword          = ConfigurationManager.AppSettings["EmailPassword"];
            _authToken  = ConfigurationManager.AppSettings["TwilioAuthToken"];
            _accountSID = ConfigurationManager.AppSettings["TwilioAccountSID"];

            //Get payfabric configs
            _payfabricDeviceId       = ConfigurationManager.AppSettings["PayfabricDeviceId"];
            _payfabricDevicePassword = ConfigurationManager.AppSettings["PayfabricDevicePassword"];
            _payfabricDeviceUrl      = ConfigurationManager.AppSettings["PayfabricDeviceUrl"];


            var smsConfigs = new InitTwoFactor()
            {
                TwoFactorAuthTimeSpan  = _twoFactorAuthTimeSpan,
                TwoFactorAuthCookie    = _twoFactorAuthCookie,
                TwoFactorAuthSmtpHost  = _twoFactorAuthSmtpHost,
                TwoFactorAuthFromEmail = _twoFactorAuthFromEmail,
                TwoFactorAuthFromPhone = _twoFactorAuthFromPhone,
                AuthToken        = _authToken,
                AccountSID       = _accountSID,
                TwoFactorEnabled = _twoFactorEnabled,
                EmailPassword    = _emailPassword
            };

            _twoFactorAuth = new TwoFactorAuth(smsConfigs);

            //repositories
            var catalogSettings        = new CatalogSettings();
            var commonSettings         = new CommonSettings();
            var categoryRepository     = new CategoryRepository(connectionString);
            var productRepository      = new ProductRepository(connectionString);
            var productCategory        = new ProductCategoryMappingRepository(connectionString);
            var shoppingCartRepository = new ShoppingCartItemRepository(connectionString);

            var _pictureBinaryRepository = new PictureBinaryRepository(connectionString);
            var _pictureRepository       = new PictureRepository(connectionString);
            var _productAttributeCombinationRepository          = new ProductAttributeCombinationRepository(connectionString);
            var _productAttributeRepository                     = new ProductAttributeRepository(connectionString);
            var _productAttributeValueRepository                = new ProductAttributeValueRepository(connectionString);
            var _productAvailabilityRangeRepository             = new ProductAvailabilityRangeRepository(connectionString);
            var _productCategoryMappingRepository               = new ProductCategoryMappingRepository(connectionString);
            var _productProductAttributeMappingRepository       = new ProductProductAttributeMappingRepository(connectionString);
            var _productProductTagMappingRepository             = new ProductTagMappingRepository(connectionString);
            var _productSpecificationAttributeMappingRepository = new ProductSpecificationAttributeRepository(connectionString);
            var _specificationAttributeOptionRepository         = new SpecificationAttributeOptionRepository(connectionString);
            var _specificationAttributeRepository               = new SpecificationAttributeRepository(connectionString);
            var _productRepository = new ProductRepository(connectionString);
            var _productManufacturerMappingRepository = new ProductManufacturerMappingRepository(connectionString);
            var _productPictureRepository             = new ProductPictureRepository(connectionString);
            var _productReviewsRepository             = new ProductReviewsRepository(connectionString);
            var _tierPricesRepository                = new TierPricesRepository(connectionString);
            var _discountProductMappingRepository    = new DiscountProductMappingRepository(connectionString);
            var _productWarehouseInventoryRepository = new ProductWarehouseInventoryRepository(connectionString);
            var _customerRepository = new CustomerRepository(connectionString);

            //services
            _categoryService = new CategoryService(catalogSettings, commonSettings, categoryRepository, productRepository, productCategory);

            _menuService    = new MenuService(_categoryService);
            _cartService    = new CartService(commonSettings, shoppingCartRepository);
            _productService = new ProductService(
                _pictureBinaryRepository,
                _pictureRepository,
                _productAttributeCombinationRepository,
                _productAttributeRepository,
                _productAttributeValueRepository,
                _productAvailabilityRangeRepository,
                _productCategoryMappingRepository,
                _productProductAttributeMappingRepository,
                _productProductTagMappingRepository,
                _productSpecificationAttributeMappingRepository,
                _specificationAttributeOptionRepository,
                _specificationAttributeRepository,
                _productRepository,
                _productManufacturerMappingRepository,
                _productPictureRepository,
                _productReviewsRepository,
                _tierPricesRepository,
                _discountProductMappingRepository,
                _productWarehouseInventoryRepository
                );
            _customerService = new CustomerService(_customerRepository);
        }