/// <summary> /// Updates the predefined product attribute value /// </summary> /// <param name="ppav">The predefined product attribute value</param> public virtual void UpdatePredefinedProductAttributeValue(PredefinedProductAttributeValue ppav) { if (ppav == null) { throw new ArgumentNullException("ppav"); } _predefinedProductAttributeValueRepository.Update(ppav); //cache _cacheManager.RemoveByPattern(PRODUCTATTRIBUTES_PATTERN_KEY); _cacheManager.RemoveByPattern(PRODUCTATTRIBUTEMAPPINGS_PATTERN_KEY); _cacheManager.RemoveByPattern(PRODUCTATTRIBUTEVALUES_PATTERN_KEY); _cacheManager.RemoveByPattern(PRODUCTATTRIBUTECOMBINATIONS_PATTERN_KEY); //event notification _eventPublisher.EntityUpdated(ppav); }
/// <summary> /// Deletes a predefined product attribute value /// </summary> /// <param name="ppav">Predefined product attribute value</param> public virtual void DeletePredefinedProductAttributeValue(PredefinedProductAttributeValue ppav) { if (ppav == null) { throw new ArgumentNullException(nameof(ppav)); } _predefinedProductAttributeValueRepository.Delete(ppav); //cache _cacheManager.RemoveByPattern(NopCatalogDefaults.ProductAttributesPatternCacheKey); _cacheManager.RemoveByPattern(NopCatalogDefaults.ProductAttributeMappingsPatternCacheKey); _cacheManager.RemoveByPattern(NopCatalogDefaults.ProductAttributeValuesPatternCacheKey); _cacheManager.RemoveByPattern(NopCatalogDefaults.ProductAttributeCombinationsPatternCacheKey); //event notification _eventPublisher.EntityDeleted(ppav); }
public string _ValueEditPopup(ProductAttributeValueViewModel model) { PredefinedProductAttributeValue _pro = new PredefinedProductAttributeValue(); _pro.Id = model.Id; _pro.Cost = model.Cost; _pro.Name = model.Name; _pro.OrderNo = model.OrderNo; _pro.ProductAttributeId = model.ProductAttributeId; if (_predefinedProductAttributeValueService.Update(_pro)) { return("1"); } else { return("-1"); } }
/// <summary> /// Inserts a predefined product attribute value /// </summary> /// <param name="ppav">The predefined product attribute value</param> public virtual void InsertPredefinedProductAttributeValue(PredefinedProductAttributeValue ppav) { if (ppav == null) { throw new ArgumentNullException(nameof(ppav)); } _predefinedProductAttributeValueRepository.Insert(ppav); //cache _cacheManager.RemoveByPrefix(QNetCatalogDefaults.ProductAttributesPrefixCacheKey); _staticCacheManager.RemoveByPrefix(QNetCatalogDefaults.ProductAttributesPrefixCacheKey); _cacheManager.RemoveByPrefix(QNetCatalogDefaults.ProductAttributeMappingsPrefixCacheKey); _cacheManager.RemoveByPrefix(QNetCatalogDefaults.ProductAttributeValuesPrefixCacheKey); _cacheManager.RemoveByPrefix(QNetCatalogDefaults.ProductAttributeCombinationsPrefixCacheKey); //event notification _eventPublisher.EntityInserted(ppav); }
public async Task <PredefinedProductAttributeValue> GetHomeDeliveryAttributeValueAsync() { ProductAttribute hdAttribute = await GetHomeDeliveryAttributeAsync(); PredefinedProductAttributeValue hdDefaultAttribute = (await _productAttributeService.GetPredefinedProductAttributeValuesAsync(hdAttribute.Id)).FirstOrDefault(); if (hdDefaultAttribute == null) { PredefinedProductAttributeValue ppav = new PredefinedProductAttributeValue(); ppav.Name = "This item will be delivered to you by ABC Warehouse"; ppav.IsPreSelected = true; ppav.PriceAdjustment = 0; ppav.ProductAttributeId = hdAttribute.Id; await _productAttributeService.InsertPredefinedProductAttributeValueAsync(ppav); hdDefaultAttribute = ppav; } return(hdDefaultAttribute); }
protected virtual List <LocalizedProperty> UpdateLocales(PredefinedProductAttributeValue ppav, PredefinedProductAttributeValueModel model) { List <LocalizedProperty> localized = new List <LocalizedProperty>(); foreach (var local in model.Locales) { if (!(String.IsNullOrEmpty(local.Name))) { localized.Add(new LocalizedProperty() { LanguageId = local.LanguageId, LocaleKey = "Name", LocaleValue = local.Name, _id = ObjectId.GenerateNewId().ToString(), Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1, }); } } return(localized); }
public ActionResult PredefinedProductAttributeValueCreatePopup(string btnId, string formId, PredefinedProductAttributeValueModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes)) { return(AccessDeniedView()); } var productAttribute = _productAttributeService.GetProductAttributeById(model.ProductAttributeId); if (productAttribute == null) { throw new ArgumentException("No product attribute found with the specified id"); } if (ModelState.IsValid) { var ppav = new PredefinedProductAttributeValue { ProductAttributeId = model.ProductAttributeId, Name = model.Name, PriceAdjustment = model.PriceAdjustment, WeightAdjustment = model.WeightAdjustment, Cost = model.Cost, IsPreSelected = model.IsPreSelected, DisplayOrder = model.DisplayOrder, _id = ObjectId.GenerateNewId().ToString(), Id = productAttribute.PredefinedProductAttributeValues.Count > 0 ? productAttribute.PredefinedProductAttributeValues.Max(x => x.Id) + 1:1, }; ppav.Locales = UpdateLocales(ppav, model); productAttribute.PredefinedProductAttributeValues.Add(ppav); _productAttributeService.UpdateProductAttribute(productAttribute); ViewBag.RefreshPage = true; ViewBag.btnId = btnId; ViewBag.formId = formId; return(View(model)); } //If we got this far, something failed, redisplay form return(View(model)); }
public virtual IActionResult PredefinedProductAttributeValueCreatePopup(PredefinedProductAttributeValueModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes)) { return(AccessDeniedView()); } //try to get a product attribute with the specified id var productAttribute = _productAttributeService.GetProductAttributeById(model.ProductAttributeId) ?? throw new ArgumentException("No product attribute found with the specified id"); if (ModelState.IsValid) { var ppav = new PredefinedProductAttributeValue { ProductAttributeId = model.ProductAttributeId, Name = model.Name, PriceAdjustment = model.PriceAdjustment, PriceAdjustmentUsePercentage = model.PriceAdjustmentUsePercentage, WeightAdjustment = model.WeightAdjustment, Cost = model.Cost, IsPreSelected = model.IsPreSelected, DisplayOrder = model.DisplayOrder }; _productAttributeService.InsertPredefinedProductAttributeValue(ppav); UpdateLocales(ppav, model); ViewBag.RefreshPage = true; return(View(model)); } //prepare model model = _productAttributeModelFactory.PreparePredefinedProductAttributeValueModel(model, productAttribute, null, true); //if we got this far, something failed, redisplay form return(View(model)); }
/// <summary> /// Prepare predefined product attribute value model /// </summary> /// <param name="model">Predefined product attribute value model</param> /// <param name="productAttribute">Product attribute</param> /// <param name="productAttributeValue">Predefined product attribute value</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>Predefined product attribute value model</returns> public virtual PredefinedProductAttributeValueModel PreparePredefinedProductAttributeValueModel(PredefinedProductAttributeValueModel model, ProductAttribute productAttribute, PredefinedProductAttributeValue productAttributeValue, bool excludeProperties = false) { if (productAttribute == null) { throw new ArgumentNullException(nameof(productAttribute)); } Action <PredefinedProductAttributeValueLocalizedModel, int> localizedModelConfiguration = null; if (productAttributeValue != null) { //fill in model values from the entity model = model ?? new PredefinedProductAttributeValueModel { ProductAttributeId = productAttributeValue.ProductAttributeId, Name = productAttributeValue.Name, PriceAdjustment = productAttributeValue.PriceAdjustment, PriceAdjustmentUsePercentage = productAttributeValue.PriceAdjustmentUsePercentage, WeightAdjustment = productAttributeValue.WeightAdjustment, Cost = productAttributeValue.Cost, IsPreSelected = productAttributeValue.IsPreSelected, DisplayOrder = productAttributeValue.DisplayOrder }; //define localized model configuration action localizedModelConfiguration = (locale, languageId) => { locale.Name = productAttributeValue.GetLocalized(entity => entity.Name, languageId, false, false); }; } model.ProductAttributeId = productAttribute.Id; //prepare localized models if (!excludeProperties) { model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration); } return(model); }
/// <summary> /// Prepare predefined product attribute value model /// </summary> /// <param name="model">Predefined product attribute value model</param> /// <param name="productAttribute">Product attribute</param> /// <param name="productAttributeValue">Predefined product attribute value</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>Predefined product attribute value model</returns> public virtual async Task <PredefinedProductAttributeValueModel> PreparePredefinedProductAttributeValueModelAsync(PredefinedProductAttributeValueModel model, ProductAttribute productAttribute, PredefinedProductAttributeValue productAttributeValue, bool excludeProperties = false) { if (productAttribute == null) { throw new ArgumentNullException(nameof(productAttribute)); } Action <PredefinedProductAttributeValueLocalizedModel, int> localizedModelConfiguration = null; if (productAttributeValue != null) { //fill in model values from the entity if (model == null) { model = productAttributeValue.ToModel <PredefinedProductAttributeValueModel>(); } //define localized model configuration action localizedModelConfiguration = async(locale, languageId) => { locale.Name = await _localizationService.GetLocalizedAsync(productAttributeValue, entity => entity.Name, languageId, false, false); }; } model.ProductAttributeId = productAttribute.Id; //prepare localized models if (!excludeProperties) { model.Locales = await _localizedModelFactory.PrepareLocalizedModelsAsync(localizedModelConfiguration); } return(model); }
public static PredefinedProductAttributeValue ToEntity(this PredefinedProductAttributeValueModel model, PredefinedProductAttributeValue destination) { return(model.MapTo(destination)); }
public static PredefinedProductAttributeValueModel ToModel(this PredefinedProductAttributeValue entity) { return(entity.MapTo <PredefinedProductAttributeValue, PredefinedProductAttributeValueModel>()); }
/// <summary> /// Updates the predefined product attribute value /// </summary> /// <param name="ppav">The predefined product attribute value</param> public virtual void UpdatePredefinedProductAttributeValue(PredefinedProductAttributeValue ppav) { _predefinedProductAttributeValueRepository.Update(ppav); }
/// <summary> /// Inserts a predefined product attribute value /// </summary> /// <param name="ppav">The predefined product attribute value</param> public virtual void InsertPredefinedProductAttributeValue(PredefinedProductAttributeValue ppav) { _predefinedProductAttributeValueRepository.Insert(ppav); }
/// <summary> /// Inserts a predefined product attribute value /// </summary> /// <param name="ppav">The predefined product attribute value</param> /// <returns>A task that represents the asynchronous operation</returns> public virtual async Task InsertPredefinedProductAttributeValueAsync(PredefinedProductAttributeValue ppav) { await _predefinedProductAttributeValueRepository.InsertAsync(ppav); }
/// <summary> /// Updates the predefined product attribute value /// </summary> /// <param name="ppav">The predefined product attribute value</param> /// <returns>A task that represents the asynchronous operation</returns> public virtual async Task UpdatePredefinedProductAttributeValueAsync(PredefinedProductAttributeValue ppav) { await _predefinedProductAttributeValueRepository.UpdateAsync(ppav); }
public static ProductAttributeValue ToEntity(this PredefinedProductAttributeValue model) { return(model.MapTo <PredefinedProductAttributeValue, ProductAttributeValue>()); }