public ActionResult Create(ServiceContent model) { try { var content = new ServiceContent { Name = model.Name.UpdatePageWebName(), Title = model.Title ?? "", TitleEn = model.TitleEn ?? "", Text = model.Text == null ? "" : HttpUtility.HtmlDecode(model.Text), TextEn = model.TextEn == null ? "" : HttpUtility.HtmlDecode(model.TextEn), SortOrder = model.SortOrder, IsSpecial = model.IsSpecial, ServiceType = model.ServiceType }; _context.ServiceContents.Add(content); _context.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { return View(); } }
public ActionResult Edit(int id, ServiceContent model) { try { var content = _context.ServiceContents.First(ea => ea.Id == id); content.Title = model.Title ?? ""; content.TitleEn = model.TitleEn ?? ""; 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(); content.IsSpecial = model.IsSpecial; content.ServiceType = model.ServiceType; _context.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }