public ActionResult Edit(int id) { var brand = _brandService.Find(id); var model = Mapper.Map <Brand, BrandEditorModel>(brand); return(View(model)); }
public ActionResult BrandUpdate(int?brandid) { if (brandid != null) { var brnd = brandservice.Find(x => x.Id == brandid).FirstOrDefault(); return(View(brnd)); } return(View()); }
public ActionResult Translate(int id, string culture) { var brand = _brandService.Find(id); var compared = new BrandModel { Id = brand.Id, Name = brand.Name, Description = brand.Description }; var translated = new BrandModel { Id = brand.Id }; var diff = new BrandModel { Id = brand.Id }; var translation = _translationStore.Find(CultureInfo.GetCultureInfo(culture), EntityKey.FromEntity(brand)); if (translation != null) { translated.Name = translation.GetTranslatedText("Name"); translated.Description = translation.GetTranslatedText("Description"); diff.Name = DiffHelper.GetDiffHtml(translation.GetOriginalText("Name"), brand.Name); diff.Description = DiffHelper.GetDiffHtml(translation.GetOriginalText("Description"), brand.Description); } ViewBag.Difference = diff; ViewBag.Compared = compared; return(View(translated)); }
private void UpdateProduct(Product product, ProductEditorModel model) { product.Name = model.Name; product.Brand = model.Brand == null ? null : _brandService.Find(model.Brand.Id); product.Categories.Clear(); foreach (var category in model.Categories) { product.Categories.Add(_categoryService.Find(category.Id)); } product.SetCustomFields(model.CustomFields); product.SetImages(model.Images); foreach (var variant in product.Variants.ToList()) { if (!model.Variants.Any(v => v.Id == variant.Id)) { product.Variants.Remove(variant); } } foreach (var variantModel in model.Variants) { ProductVariant variant; if (variantModel.Id > 0) { variant = product.Variants.FirstOrDefault(v => v.Id == variantModel.Id); } else { variant = new ProductVariant(); product.Variants.Add(variant); } variant.Sku = variantModel.Sku; variant.Price = variantModel.Price; variant.SetVariantFields(variantModel.VariantFields); } }