MusicShop/Controllers/AdminController.cs

(开头部分) 13KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MusicShop.Models;

namespace MusicShop.Controllers
{
    public class AdminController : Controller
    {
        MusicDBEntities dBEntities = new MusicDBEntities();
        // GET: Admin
        public ActionResult Index()
        {
            return CheckSafe(View(), null);
        }
        public ActionResult GenresManager()
        {
            var temp = dBEntities.Genres.ToList();
            return CheckSafe(null, PartialView(temp));
        }
        [HttpPost]
        public ActionResult AddGenres()
        {
            Genres g = new Genres()
            {
                Name = "",
                Description = ""
            };
            return CheckSafe(null, PartialView(g));
        }
        [HttpPost]
        public ActionResult EditGenres()
        {
            int gId = Convert.ToInt32(RouteData.Values["id"]);
            var temp = dBEntities.Genres.Where(x => x.GenreId == gId).FirstOrDefault();
            return CheckSafe(null, PartialView("AddGenres", temp));
        }
        [HttpPost]
        public string SaveGenres(Genres genre)
        {
            if (!ModelState.IsValid)
            {
                return "noValid";
            }
            if (genre.GenreId == 0)
            {
                dBEntities.Genres.Add(genre);
            }
            else
            {
                var temp = dBEntities.Genres.Where(x => x.GenreId == genre.GenreId).FirstOrDefault();
                if (temp.Name.Equals(genre.Name) && temp.Description.Equals(genre.Description))
                {
                    return "success";
                }
                temp.Name = genre.Name;
                temp.Description = genre.Description;
后面还有 310 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。