public ActionResult Create(ArticleViewModel vm) { if (ModelState.IsValid) { vm.Article.ArticleHeadline = new MultiLangString(vm.ArticleHeadline, CultureHelper.GetCurrentNeutralUICulture(), vm.ArticleHeadline, nameof(vm.Article) + "." + vm.Article.ArticleId + "." + nameof(vm.Article.ArticleHeadline)); vm.Article.ArticleBody = new MultiLangString(vm.ArticleBody, CultureHelper.GetCurrentNeutralUICulture(), vm.ArticleBody, nameof(vm.Article) + "." + vm.Article.ArticleId + "." + nameof(vm.Article.ArticleBody)); _uow.Articles.Add(vm.Article); _uow.Commit(); return RedirectToAction(nameof(Index)); } return View(vm); }
// GET: Admin/Articles/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Article article = _uow.Articles.GetById(id); if (article == null) { return HttpNotFound(); } var vm = new ArticleViewModel { Article = article, ArticleHeadline = article.ArticleHeadline.Translate(), ArticleBody = article.ArticleBody.Translate() }; return View(vm); }
public ActionResult Edit(ArticleViewModel vm) { if (ModelState.IsValid) { vm.Article.ArticleHeadline = _uow.MultiLangStrings.GetById(vm.Article.ArticleHeadlineId); vm.Article.ArticleHeadline.SetTranslation(vm.ArticleHeadline, CultureHelper.GetCurrentNeutralUICulture(), nameof(vm.Article) + "." + vm.Article.ArticleId + "." + nameof(vm.Article.ArticleHeadline)); vm.Article.ArticleBody = _uow.MultiLangStrings.GetById(vm.Article.ArticleBodyId); vm.Article.ArticleBody.SetTranslation(vm.ArticleBody, CultureHelper.GetCurrentNeutralUICulture(), nameof(vm.Article) + "." + vm.Article.ArticleId + "." + nameof(vm.Article.ArticleBody)); _uow.Articles.Update(vm.Article); _uow.Commit(); return RedirectToAction(nameof(Index)); } return View(vm); }