public IActionResult Edit([FromBody] Sidebar sidebar)
        {
            _context.Update(sidebar);
            _context.SaveChanges();

            return(Json("ok"));
        }
Exemplo n.º 2
0
        public IActionResult Edit(int id, [FromBody] Page page)
        {
            page.Slug       = page.Title.Replace(" ", "-").ToLower();
            page.HasSidebar = page.HasSidebar ?? "no";

            var existingPage = _context.Pages.FirstOrDefault(
                p =>
                p.Slug == page.Slug &&
                p.ID != id);

            if (existingPage != null)
            {
                return(Json("pageExists"));
            }
            else
            {
                _context.Update(page);
                _context.SaveChanges();

                return(Json("ok"));
            }
        }