public VArtist(Artist artist) { ArtistId = artist.ArtistID; ArtistName = artist.ArtistName; Gender = artist.Gender; Hometown = artist.Hometown; Song = artist.Song; }
public JsonResult AjaxCreate(Artist artist) { if (ModelState.IsValid) { artist.ArtistID = Guid.NewGuid(); db.Artist.Add(artist); db.SaveChanges(); return Json(new { Success = true, ArtistID = artist.ArtistID }); } ViewBag.ArtistGender = new SelectList(db.Gender, "GenderID", "GenderName", artist.ArtistGender); ViewBag.ArtistHometown = new SelectList(db.Hometown, "HometownID", "HometownName", artist.ArtistHometown); return Json(new {Success = false, Message = "创建失败!"}, JsonRequestBehavior.AllowGet); }
public ActionResult Create(Artist artist) { if (ModelState.IsValid) { artist.ArtistID = Guid.NewGuid(); db.Artist.Add(artist); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ArtistGender = new SelectList(db.Gender, "GenderID", "GenderName", artist.ArtistGender); ViewBag.ArtistHometown = new SelectList(db.Hometown, "HometownID", "HometownName", artist.ArtistHometown); return View(artist); }
public ActionResult Edit(Artist artist) { if (ModelState.IsValid) { db.Entry(artist).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ArtistGender = new SelectList(db.Gender, "GenderID", "GenderName", artist.ArtistGender); ViewBag.ArtistHometown = new SelectList(db.Hometown, "HometownID", "HometownName", artist.ArtistHometown); return View(artist); }