예제 #1
0
        /// <summary>
        /// Inserts an email account
        /// </summary>
        /// <param name="emailAccount">Email account</param>
        public virtual async Task InsertEmailAccount(EmailAccount emailAccount)
        {
            if (emailAccount == null)
            {
                throw new ArgumentNullException(nameof(emailAccount));
            }

            emailAccount.Email       = CommonHelper.EnsureNotNull(emailAccount.Email);
            emailAccount.DisplayName = CommonHelper.EnsureNotNull(emailAccount.DisplayName);
            emailAccount.Host        = CommonHelper.EnsureNotNull(emailAccount.Host);
            emailAccount.Username    = CommonHelper.EnsureNotNull(emailAccount.Username);
            emailAccount.Password    = CommonHelper.EnsureNotNull(emailAccount.Password);

            emailAccount.Email       = emailAccount.Email.Trim();
            emailAccount.DisplayName = emailAccount.DisplayName.Trim();
            emailAccount.Host        = emailAccount.Host.Trim();
            emailAccount.Username    = emailAccount.Username.Trim();
            emailAccount.Password    = emailAccount.Password.Trim();

            emailAccount.Email       = CommonHelper.EnsureMaximumLength(emailAccount.Email, 255);
            emailAccount.DisplayName = CommonHelper.EnsureMaximumLength(emailAccount.DisplayName, 255);
            emailAccount.Host        = CommonHelper.EnsureMaximumLength(emailAccount.Host, 255);
            emailAccount.Username    = CommonHelper.EnsureMaximumLength(emailAccount.Username, 255);
            emailAccount.Password    = CommonHelper.EnsureMaximumLength(emailAccount.Password, 255);

            await _emailAccountRepository.InsertAsync(emailAccount);

            //clear cache
            await _cacheBase.RemoveByPrefix(CacheKey.EMAILACCOUNT_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(emailAccount);
        }
        public async Task Handle(EntityUpdated <Product> eventMessage, CancellationToken cancellationToken)
        {
            await _cacheBase.RemoveByPrefix(CacheKeyConst.HOMEPAGE_BESTSELLERS_IDS_PATTERN_KEY);

            await _cacheBase.RemoveByPrefix(string.Format(CacheKeyConst.PRODUCTS_SIMILAR_IDS_PATTERN_KEY, eventMessage.Entity.Id));

            await _cacheBase.RemoveAsync(string.Format(CacheKeyConst.PRODUCTS_RELATED_IDS_PATTERN_KEY, eventMessage.Entity.Id));
        }
예제 #3
0
        public virtual async Task DeleteShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)
        {
            if (shippingByWeightRecord == null)
            {
                throw new ArgumentNullException("shippingByWeightRecord");
            }

            await _sbwRepository.DeleteAsync(shippingByWeightRecord);

            await _cacheBase.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);
        }
예제 #4
0
        /// <summary>
        /// Delete a permission
        /// </summary>
        /// <param name="permission">Permission</param>
        public virtual async Task DeletePermission(Permission permission)
        {
            if (permission == null)
            {
                throw new ArgumentNullException(nameof(permission));
            }

            await _permissionRepository.DeleteAsync(permission);

            await _cacheBase.RemoveByPrefix(CacheKey.PERMISSIONS_PATTERN_KEY);
        }
예제 #5
0
        /// <summary>
        /// Inserts a pickup point
        /// </summary>
        /// <param name="pickupPoint">Pickup point</param>
        public virtual async Task InsertStoreShippingPoint(ShippingPoints pickupPoint)
        {
            if (pickupPoint == null)
            {
                throw new ArgumentNullException("pickupPoint");
            }

            await _shippingPointRepository.InsertAsync(pickupPoint);

            await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);
        }
예제 #6
0
        public async Task Handle(EntityDeleted <Discount> notification, CancellationToken cancellationToken)
        {
            var discount = notification.Entity;

            var builder = Builders <BsonDocument> .Filter;

            if (discount.DiscountTypeId == DiscountType.AssignedToSkus)
            {
                var builderproduct = Builders <Product> .Update;
                var updatefilter   = builderproduct.Pull(x => x.AppliedDiscounts, discount.Id);
                await _productRepository.Collection.UpdateManyAsync(new BsonDocument(), updatefilter);

                await _cacheBase.RemoveByPrefix(CacheKey.PRODUCTS_PATTERN_KEY);
            }

            if (discount.DiscountTypeId == DiscountType.AssignedToCategories)
            {
                var buildercategory = Builders <Category> .Update;
                var updatefilter    = buildercategory.Pull(x => x.AppliedDiscounts, discount.Id);
                await _categoryRepository.Collection.UpdateManyAsync(new BsonDocument(), updatefilter);

                await _cacheBase.RemoveByPrefix(CacheKey.CATEGORIES_PATTERN_KEY);
            }
            if (discount.DiscountTypeId == DiscountType.AssignedToBrands)
            {
                var builderbrand = Builders <Brand> .Update;
                var updatefilter = builderbrand.Pull(x => x.AppliedDiscounts, discount.Id);
                await _brandRepository.Collection.UpdateManyAsync(new BsonDocument(), updatefilter);

                await _cacheBase.RemoveByPrefix(CacheKey.BRANDS_PATTERN_KEY);
            }
            if (discount.DiscountTypeId == DiscountType.AssignedToCollections)
            {
                var buildercollection = Builders <Collection> .Update;
                var updatefilter      = buildercollection.Pull(x => x.AppliedDiscounts, discount.Id);
                await _collectionRepository.Collection.UpdateManyAsync(new BsonDocument(), updatefilter);

                await _cacheBase.RemoveByPrefix(CacheKey.COLLECTIONS_PATTERN_KEY);
            }
            if (discount.DiscountTypeId == DiscountType.AssignedToVendors)
            {
                var buildervendor = Builders <Vendor> .Update;
                var updatefilter  = buildervendor.Pull(x => x.AppliedDiscounts, discount.Id);
                await _vendorRepository.Collection.UpdateManyAsync(new BsonDocument(), updatefilter);

                await _cacheBase.RemoveByPrefix(CacheKey.PRODUCTS_PATTERN_KEY);
            }

            //remove coupon codes
            var filtersCoupon = Builders <DiscountCoupon> .Filter;
            var filterCrp     = filtersCoupon.Eq(x => x.DiscountId, discount.Id);

            await _discountCouponRepository.Collection.DeleteManyAsync(filterCrp);
        }
예제 #7
0
        /// <summary>
        /// Inserts an activity log type item
        /// </summary>
        /// <param name="activityLogType">Activity log type item</param>
        public virtual async Task InsertActivityType(ActivityLogType activityLogType)
        {
            if (activityLogType == null)
            {
                throw new ArgumentNullException(nameof(activityLogType));
            }

            await _activityLogTypeRepository.InsertAsync(activityLogType);

            await _cacheBase.RemoveByPrefix(CacheKey.ACTIVITYTYPE_PATTERN_KEY);
        }
        /// <summary>
        /// Deletes an URL record
        /// </summary>
        /// <param name="urlRecord">URL record</param>
        public virtual async Task DeleteUrlRecord(UrlRecord urlRecord)
        {
            if (urlRecord == null)
            {
                throw new ArgumentNullException("urlRecord");
            }

            await _urlRecordRepository.DeleteAsync(urlRecord);

            //cache
            await _cacheBase.RemoveByPrefix(CacheKey.URLRECORD_PATTERN_KEY);
        }
예제 #9
0
        /// <summary>
        /// Delete a slider
        /// </summary>
        /// <param name="slider">Slider</param>
        public virtual async Task DeleteSlider(PictureSlider slide)
        {
            if (slide == null)
            {
                throw new ArgumentNullException(nameof(slide));
            }

            //clear cache
            await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);

            await _reporistoryPictureSlider.DeleteAsync(slide);
        }
예제 #10
0
        /// <summary>
        /// Inserts an URL Entity
        /// </summary>
        /// <param name="urlEntity">URL Entity</param>
        public virtual async Task InsertEntityUrl(EntityUrl urlEntity)
        {
            if (urlEntity == null)
            {
                throw new ArgumentNullException(nameof(urlEntity));
            }

            await _urlEntityRepository.InsertAsync(urlEntity);

            //cache
            await _cacheBase.RemoveByPrefix(CacheKey.URLEntity_PATTERN_KEY);
        }
예제 #11
0
        /// <summary>
        /// Deletes a tax rate
        /// </summary>
        /// <param name="taxRate">Tax rate</param>
        public virtual async Task DeleteTaxRate(TaxRate taxRate)
        {
            if (taxRate == null)
            {
                throw new ArgumentNullException("taxRate");
            }

            await _taxRateRepository.DeleteAsync(taxRate);

            await _cacheBase.RemoveByPrefix(TAXRATE_PATTERN_KEY);

            //event notification
            await _mediator.EntityDeleted(taxRate);
        }
예제 #12
0
        /// <summary>
        /// Inserts a customer group
        /// </summary>
        /// <param name="customerGroup">Customer group</param>
        public virtual async Task InsertCustomerGroup(CustomerGroup customerGroup)
        {
            if (customerGroup == null)
            {
                throw new ArgumentNullException(nameof(customerGroup));
            }

            await _customerGroupRepository.InsertAsync(customerGroup);

            await _cacheBase.RemoveByPrefix(CacheKey.CUSTOMERGROUPS_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(customerGroup);
        }
예제 #13
0
        /// <summary>
        /// Deletes measure dimension
        /// </summary>
        /// <param name="measureDimension">Measure dimension</param>
        public virtual async Task DeleteMeasureDimension(MeasureDimension measureDimension)
        {
            if (measureDimension == null)
            {
                throw new ArgumentNullException("measureDimension");
            }

            await _measureDimensionRepository.DeleteAsync(measureDimension);

            await _cacheBase.RemoveByPrefix(CacheKey.MEASUREDIMENSIONS_PATTERN_KEY);

            //event notification
            await _mediator.EntityDeleted(measureDimension);
        }
예제 #14
0
        /// <summary>
        /// Inserts a measure dimension
        /// </summary>
        /// <param name="measure">Measure dimension</param>
        public virtual async Task InsertMeasureDimension(MeasureDimension measure)
        {
            if (measure == null)
            {
                throw new ArgumentNullException(nameof(measure));
            }

            await _measureDimensionRepository.InsertAsync(measure);

            await _cacheBase.RemoveByPrefix(CacheKey.MEASUREDIMENSIONS_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(measure);
        }
예제 #15
0
        /// <summary>
        /// Inserts a country
        /// </summary>
        /// <param name="country">Country</param>
        public virtual async Task InsertCountry(Country country)
        {
            if (country == null)
            {
                throw new ArgumentNullException(nameof(country));
            }

            await _countryRepository.InsertAsync(country);

            await _cacheBase.RemoveByPrefix(CacheKey.COUNTRIES_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(country);
        }
예제 #16
0
        /// <summary>
        /// Inserts a tax category
        /// </summary>
        /// <param name="taxCategory">Tax category</param>
        public virtual async Task InsertTaxCategory(TaxCategory taxCategory)
        {
            if (taxCategory == null)
            {
                throw new ArgumentNullException(nameof(taxCategory));
            }

            await _taxCategoryRepository.InsertAsync(taxCategory);

            await _cacheBase.RemoveByPrefix(CacheKey.TAXCATEGORIES_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(taxCategory);
        }
예제 #17
0
        /// <summary>
        /// Inserts a currency
        /// </summary>
        /// <param name="currency">Currency</param>
        public virtual async Task InsertCurrency(Currency currency)
        {
            if (currency == null)
            {
                throw new ArgumentNullException(nameof(currency));
            }

            await _currencyRepository.InsertAsync(currency);

            await _cacheBase.RemoveByPrefix(CacheKey.CURRENCIES_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(currency);
        }
        /// <summary>
        /// Delete a message template
        /// </summary>
        /// <param name="messageTemplate">Message template</param>
        public virtual async Task DeleteMessageTemplate(MessageTemplate messageTemplate)
        {
            if (messageTemplate == null)
            {
                throw new ArgumentNullException("messageTemplate");
            }

            await _messageTemplateRepository.DeleteAsync(messageTemplate);

            await _cacheBase.RemoveByPrefix(CacheKey.MESSAGETEMPLATES_PATTERN_KEY);

            //event notification
            await _mediator.EntityDeleted(messageTemplate);
        }
        /// <summary>
        /// Deletes a state/province
        /// </summary>
        /// <param name="stateProvince">The state/province</param>
        public virtual async Task DeleteStateProvince(StateProvince stateProvince)
        {
            if (stateProvince == null)
            {
                throw new ArgumentNullException("stateProvince");
            }

            await _stateProvinceRepository.DeleteAsync(stateProvince);

            await _cacheBase.RemoveByPrefix(CacheKey.STATEPROVINCES_PATTERN_KEY);

            //event notification
            await _mediator.EntityDeleted(stateProvince);
        }
예제 #20
0
        /// <summary>
        /// Updates the picture
        /// </summary>
        /// <param name="pictureId">The picture identifier</param>
        /// <param name="pictureBinary">The picture binary</param>
        /// <param name="mimeType">The picture MIME type</param>
        /// <param name="seoFilename">The SEO filename</param>
        /// <param name="altAttribute">"alt" attribute for "img" HTML element</param>
        /// <param name="titleAttribute">"title" attribute for "img" HTML element</param>
        /// <param name="isNew">A value indicating whether the picture is new</param>
        /// <param name="validateBinary">A value indicating whether to validated provided picture binary</param>
        /// <returns>Picture</returns>
        public virtual async Task <Picture> UpdatePicture(string pictureId, byte[] pictureBinary, string mimeType,
                                                          string seoFilename, string altAttribute = null, string titleAttribute = null,
                                                          bool isNew = true, bool validateBinary = true)
        {
            mimeType = CommonHelper.EnsureNotNull(mimeType);
            mimeType = CommonHelper.EnsureMaximumLength(mimeType, 20);

            seoFilename = CommonHelper.EnsureMaximumLength(seoFilename, 100);

            if (validateBinary)
            {
                pictureBinary = ValidatePicture(pictureBinary, mimeType);
            }

            var picture = await GetPictureById(pictureId);

            if (picture == null)
            {
                return(null);
            }

            //delete old thumbs if a picture has been changed
            if (seoFilename != picture.SeoFilename)
            {
                await DeletePictureThumbs(picture);
            }

            picture.PictureBinary  = _mediaSettings.StoreInDb ? pictureBinary : new byte[0];
            picture.MimeType       = mimeType;
            picture.SeoFilename    = seoFilename;
            picture.AltAttribute   = altAttribute;
            picture.TitleAttribute = titleAttribute;
            picture.IsNew          = isNew;

            await _pictureRepository.UpdateAsync(picture);

            if (!_mediaSettings.StoreInDb)
            {
                await SavePictureInFile(picture.Id, pictureBinary, mimeType);
            }

            //event notification
            await _mediator.EntityUpdated(picture);

            //clare cache
            await _cacheBase.RemoveByPrefix(string.Format(CacheKey.PICTURE_BY_ID, picture.Id));

            return(picture);
        }
예제 #21
0
        /// <summary>
        /// Inserts a brand
        /// </summary>
        /// <param name="brand">Brand</param>
        public virtual async Task InsertBrand(Brand brand)
        {
            if (brand == null)
            {
                throw new ArgumentNullException(nameof(brand));
            }

            await _brandRepository.InsertAsync(brand);

            //cache
            await _cacheBase.RemoveByPrefix(CacheKey.BRANDS_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(brand);
        }
예제 #22
0
        /// <summary>
        /// Inserts a warehouse
        /// </summary>
        /// <param name="warehouse">Warehouse</param>
        public virtual async Task InsertPickupPoint(PickupPoint pickupPoint)
        {
            if (pickupPoint == null)
            {
                throw new ArgumentNullException(nameof(pickupPoint));
            }

            await _pickupPointsRepository.InsertAsync(pickupPoint);

            //clear cache
            await _cacheBase.RemoveByPrefix(CacheKey.PICKUPPOINTS_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(pickupPoint);
        }
예제 #23
0
        /// <summary>
        /// Inserts a sales employee
        /// </summary>
        /// <param name="salesEmployee">Sales Employee</param>
        public virtual async Task InsertSalesEmployee(SalesEmployee salesEmployee)
        {
            if (salesEmployee == null)
            {
                throw new ArgumentNullException(nameof(salesEmployee));
            }

            await _salesEmployeeRepository.InsertAsync(salesEmployee);

            //clear cache
            await _cacheBase.RemoveByPrefix(CacheKey.SALESEMPLOYEE_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(salesEmployee);
        }
예제 #24
0
        /// <summary>
        /// Inserts page layout
        /// </summary>
        /// <param name="pageLayout">Page layout</param>
        public virtual async Task InsertPageLayout(PageLayout pageLayout)
        {
            if (pageLayout == null)
            {
                throw new ArgumentNullException(nameof(pageLayout));
            }

            await _pageLayoutRepository.InsertAsync(pageLayout);

            //clear cache
            await _cacheBase.RemoveByPrefix(CacheKey.PAGE_LAYOUT_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(pageLayout);
        }
예제 #25
0
        /// <summary>
        /// Deletes an ACL record
        /// </summary>
        /// <param name="aclRecord">ACL record</param>
        public virtual async Task DeleteAclRecord(AclRecord aclRecord)
        {
            if (aclRecord == null)
            {
                throw new ArgumentNullException("aclRecord");
            }

            await _aclRecordRepository.DeleteAsync(aclRecord);

            //cache
            await _cacheBase.RemoveByPrefix(CacheKey.ACLRECORD_PATTERN_KEY);

            //event notification
            await _mediator.EntityDeleted(aclRecord);
        }
예제 #26
0
        /// <summary>
        /// Inserts a order's tag
        /// </summary>
        /// <param name="orderTag">Order's tag</param>
        public virtual async Task InsertOrderTag(OrderTag orderTag)
        {
            if (orderTag == null)
            {
                throw new ArgumentNullException(nameof(orderTag));
            }

            await _orderTagRepository.InsertAsync(orderTag);

            //cache
            await _cacheBase.RemoveByPrefix(CacheKey.ORDERTAG_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(orderTag);
        }
        /// <summary>
        /// Deletes a language
        /// </summary>
        /// <param name="language">Language</param>
        public virtual async Task DeleteLanguage(Language language)
        {
            if (language == null)
            {
                throw new ArgumentNullException("language");
            }

            await _languageRepository.DeleteAsync(language);

            //cache
            await _cacheBase.RemoveByPrefix(CacheKey.LANGUAGES_PATTERN_KEY);

            //event notification
            await _mediator.EntityDeleted(language);
        }
예제 #28
0
        /// <summary>
        /// Deletes a locale string resource
        /// </summary>
        /// <param name="localeStringResource">Locale string resource</param>
        public virtual async Task DeleteLocaleStringResource(LocaleStringResource localeStringResource)
        {
            if (localeStringResource == null)
            {
                throw new ArgumentNullException("localeStringResource");
            }

            await _lsrRepository.DeleteAsync(localeStringResource);

            //cache
            await _cacheBase.RemoveByPrefix(CacheKey.LOCALSTRINGRESOURCES_PATTERN_KEY);

            //event notification
            await _mediator.EntityDeleted(localeStringResource);
        }
예제 #29
0
        /// <summary>
        /// Inserts a delivery date
        /// </summary>
        /// <param name="deliveryDate">Delivery date</param>
        public virtual async Task InsertDeliveryDate(DeliveryDate deliveryDate)
        {
            if (deliveryDate == null)
            {
                throw new ArgumentNullException(nameof(deliveryDate));
            }

            await _deliveryDateRepository.InsertAsync(deliveryDate);

            //clear cache
            await _cacheBase.RemoveByPrefix(CacheKey.DELIVERYDATE_PATTERN_KEY);

            //event notification
            await _mediator.EntityInserted(deliveryDate);
        }
        /// <summary>
        /// Inserts a merchandise return action
        /// </summary>
        /// <param name="merchandiseReturnAction">Merchandise return action</param>
        public virtual async Task InsertMerchandiseReturnAction(MerchandiseReturnAction merchandiseReturnAction)
        {
            if (merchandiseReturnAction == null)
            {
                throw new ArgumentNullException(nameof(merchandiseReturnAction));
            }

            await _merchandiseReturnActionRepository.InsertAsync(merchandiseReturnAction);

            //event notification
            await _mediator.EntityInserted(merchandiseReturnAction);

            //clear cache
            await _cacheBase.RemoveByPrefix(CacheKey.MERCHANDISE_RETURN_ACTIONS_ALL_KEY);
        }