public ActionResult Create(StaticPageModel pageModel) { if (ModelState.IsValid) { try { User user = _authenService.GetAuthenticatedUser(); StaticPage page = pageModel.ToEntity(); page.Created = DateTime.Now; page.Modified = page.Created; page.CreatedBy = user.Id; page.ModifiedBy = page.CreatedBy; _pageService.AddPage(page); return(RedirectToAction("Index")); } catch (Exception e) { ErrorNotification(e.ToString()); } } else { AddModelStateErrors(); } Title = "Thêm mới trang tĩnh"; ViewData["ToolbarTitle"] = Title; return(View()); }
public ActionResult Edit([Bind(Include = "Id,Content,Title")] StaticPageModel staticPage) { if (ModelState.IsValid) { db.Entry(StaticPageModel.ToEntity(staticPage)).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(staticPage)); }
public ActionResult Create([Bind(Include = "Id,Content,Title")] StaticPageModel staticPage) { if (ModelState.IsValid) { db.StaticPages.Add(StaticPageModel.ToEntity(staticPage)); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(staticPage)); }