public ActionResult Create(Content model) { try { var content = new Content { Name = model.Name.UpdatePageWebName(), Title = model.Title ?? "", TitleEn = model.TitleEn ?? "", MenuTitle = model.Title ?? "", MenuTitleEn = model.TitleEn ?? "", Text = model.Text == null ? "" : HttpUtility.HtmlDecode(model.Text), TextEn = model.TextEn == null ? "" : HttpUtility.HtmlDecode(model.TextEn), SortOrder = model.SortOrder }; _context.Contents.Add(content); _context.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { return View(); } }
public ActionResult Edit(int id, Content model) { try { var content = _context.Contents.First(ea => ea.Id == id); content.Title = model.Title ?? ""; content.TitleEn = model.TitleEn ?? ""; content.MenuTitle = model.MenuTitle ?? ""; content.MenuTitleEn = model.MenuTitleEn ?? ""; content.Text = model.Text == null ? "" : HttpUtility.HtmlDecode(model.Text); content.TextEn = model.TextEn == null ? "" : HttpUtility.HtmlDecode(model.TextEn); content.SortOrder = model.SortOrder; content.Name = model.Name.UpdatePageWebName(); _context.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }