Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using Microsoft.AspNetCore.Mvc;
- using Site.Data;
- using System.Threading.Tasks;
- using Microsoft.EntityFrameworkCore;
- using Site.Data.Models;
- namespace Ad.Areas.Admin.Controllers
- {
- [Area("Admin")]
- // [Authorize(Roles = "Admin")]
- public class PageController : Controller
- {
- private readonly ApplicationContext _context;
- public PageController(ApplicationContext context)
- {
- _context = context;
- }
- public async Task<IActionResult> Index()
- {
- return View(await _context.Pages
- .OrderBy(a=>a.Position) //not working
- .ToListAsync());
- }
- public IActionResult Edit(int id)
- {
- return View(_context.Pages.Find(id));
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public async Task<IActionResult> Edit(Page page)
- {
- if (ModelState.IsValid)
- {
- _context.Update(page);
- await _context.SaveChangesAsync();
- return RedirectToAction(nameof(Index));
- }
- return View(page);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement