// 流派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); }
// 流派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); }
//歌手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); }
// 歌手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); }
//用户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); }
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")); }
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")); }
public ActionResult GenreCreate(ManagViewModel Manag) { Genre genre = MapTo(Manag); if (Manag != null) { db.Genres.Add(genre); db.SaveChanges(); return(RedirectToAction("GenreIndex")); } return(View()); }
//用户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); }
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); }
public ActionResult UserCreate(ManagViewModel Manag) { User user = UserView(Manag); if (Manag != null) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("UserIndex")); } return(View()); }
public ActionResult SingerCreate(ManagViewModel Manag) { Singer singer = singerMod(Manag); if (Manag != null) { db.Singers.Add(singer); db.SaveChanges(); return(RedirectToAction("SingerIndex")); } return(View()); }
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")); }