protected virtual void UpdateLocales(ProductTag productTag, ProductTagModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(productTag, x => x.Name, localized.Name, localized.LanguageId); } }
//edit public ActionResult EditProductTag(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProductTags)) return AccessDeniedView(); var productTag = _productTagService.GetProductTagById(id); if (productTag == null) //No product tag found with the specified id return RedirectToAction("List"); var model = new ProductTagModel { Id = productTag.Id, Name = productTag.Name, ProductCount = _productTagService.GetProductCount(productTag.Id, 0) }; //locales AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = productTag.GetLocalized(x => x.Name, languageId, false, false); }); return View(model); }
public ActionResult EditProductTag(string btnId, string formId, ProductTagModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProductTags)) return AccessDeniedView(); var productTag = _productTagService.GetProductTagById(model.Id); if (productTag == null) //No product tag found with the specified id return RedirectToAction("List"); if (ModelState.IsValid) { productTag.Name = model.Name; _productTagService.UpdateProductTag(productTag); //locales UpdateLocales(productTag, model); ViewBag.RefreshPage = true; ViewBag.btnId = btnId; ViewBag.formId = formId; return View(model); } //If we got this far, something failed, redisplay form return View(model); }
protected virtual List<LocalizedProperty> UpdateLocales(ProductTag productTag, ProductTagModel 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; }