Пример #1
0
        // 流派ViewModel转Model
        private Genre MapTo(ManagViewModel genreManag)
        {
            Genre genre = new Genre();

            genre.GenreId   = genreManag.GenreId;
            genre.Describe  = genreManag.Describe;
            genre.GenreName = genreManag.GenreName;
            return(genre);
        }
Пример #2
0
        // 流派Model转ViewModel
        private ManagViewModel MapToModel(Genre genre)
        {
            ManagViewModel Manag = new ManagViewModel();

            Manag.GenreId   = genre.GenreId;
            Manag.Describe  = genre.Describe;
            Manag.GenreName = genre.GenreName;
            return(Manag);
        }
Пример #3
0
        //歌手Model转ViewModel
        private ManagViewModel Singer(Singer singer)
        {
            ManagViewModel Manag = new ManagViewModel();

            Manag.SingerId   = singer.SingerId;
            Manag.SingerName = singer.SingerName;
            Manag.Gender     = singer.Gender;
            Manag.Introduce  = singer.Introduce;
            return(Manag);
        }
Пример #4
0
        // 歌手ViewModel转Model

        private Singer singerMod(ManagViewModel Manag)
        {
            Singer singer = new Singer();

            singer.SingerId   = Manag.SingerId;
            singer.SingerName = Manag.SingerName;
            singer.Gender     = Manag.Gender;
            singer.Introduce  = Manag.Introduce;
            return(singer);
        }
Пример #5
0
        //用户Model转ViewModel
        private ManagViewModel UserModel(User user)
        {
            ManagViewModel Manag = new ManagViewModel();

            Manag.UserId   = user.UserId;
            Manag.Email    = user.Email;
            Manag.Password = user.Password;
            Manag.UserName = user.UserName;
            Manag.Regtime  = user.Regtime;
            return(Manag);
        }
Пример #6
0
 public ActionResult Initial(ManagViewModel Manag)
 {
     if (Manag != null)
     {
         User user = InitialModel(Manag);
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("UserIndex"));
     }
     return(RedirectToAction("UserIndex"));
 }
Пример #7
0
 public ActionResult SingerEdit(ManagViewModel Manag)
 {
     if (Manag != null)
     {
         Singer singer = singerMod(Manag);
         db.Entry(singer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("SingerIndex"));
     }
     return(RedirectToAction("SingerIndex"));
 }
Пример #8
0
        public ActionResult GenreCreate(ManagViewModel Manag)
        {
            Genre genre = MapTo(Manag);

            if (Manag != null)
            {
                db.Genres.Add(genre);
                db.SaveChanges();
                return(RedirectToAction("GenreIndex"));
            }
            return(View());
        }
Пример #9
0
        //用户ViewModel转Model
        private User UserView(ManagViewModel Manag)
        {
            User user = new User();

            user.UserId   = Manag.UserId;
            user.RoleId   = 1;
            user.Email    = Manag.Email;
            user.Password = Manag.Password;
            user.UserName = Manag.UserName;
            user.Regtime  = DateTime.Now;
            return(user);
        }
Пример #10
0
        private User InitialModel(ManagViewModel Manag)
        {
            User user = new User();

            user.UserId   = Manag.UserId;
            user.RoleId   = 1;
            user.Email    = Manag.Email;
            user.Password = "******";
            user.UserName = Manag.UserName;
            user.Regtime  = Manag.Regtime;
            return(user);
        }
Пример #11
0
        public ActionResult UserCreate(ManagViewModel Manag)
        {
            User user = UserView(Manag);

            if (Manag != null)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("UserIndex"));
            }
            return(View());
        }
Пример #12
0
        public ActionResult SingerCreate(ManagViewModel Manag)
        {
            Singer singer = singerMod(Manag);

            if (Manag != null)
            {
                db.Singers.Add(singer);
                db.SaveChanges();
                return(RedirectToAction("SingerIndex"));
            }
            return(View());
        }
Пример #13
0
        public ActionResult GenreEdit(ManagViewModel Manag)
        {
            if (Manag != null)
            {
                Genre genre = MapTo(Manag);
                db.Entry(genre).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("GenreIndex"));
            }
            var genres = db.Genres.Find(Manag.GenreId);

            //return View(GenreManag);
            return(RedirectToAction("GenreIndex"));
        }