Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
        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));
        }