public ActionResult Translate(string culture, int id) { var category = _repository.Find(id); var compared = new CategoryModel(category); var translated = new CategoryModel { Id = category.Id }; var diff = new CategoryModel { Id = category.Id }; var translation = _translationStore.Find(CultureInfo.GetCultureInfo(culture), new EntityKey(typeof(Category), category.Id)); if (translation != null) { translated.Name = translation.GetTranslatedText("Name"); translated.Description = translation.GetTranslatedText("Description"); diff.Name = DiffHelper.GetDiffHtml(translation.GetOriginalText("Name"), category.Name); diff.Description = DiffHelper.GetDiffHtml(translation.GetOriginalText("Description"), category.Description); } ViewBag.Compared = compared; ViewBag.Difference = diff; return View(translated); }
public ActionResult Translate(string culture, CategoryModel model, string @return) { var key = new EntityKey(typeof(Category), model.Id); var category = _repository.Find(model.Id); _translationStore.AddOrUpdate(CultureInfo.GetCultureInfo(culture), key, new List<PropertyTranslation> { new PropertyTranslation("Name", category.Name, model.Name), new PropertyTranslation("Description", category.Description, model.Description) }); return AjaxForm().RedirectTo(@return); }