public ActionResult Create(ArtworkControllerModel model) { Artwork artwork = model.GetArtwork(db); if(ModelState.IsValid) { db.Artworks.Add(artwork); db.SaveChanges(); return RedirectToAction("Index"); } return View(artwork); }
public ActionResult Edit(ArtworkControllerModel model) { if(ModelState.IsValid) { Artwork artwork = model.GetArtwork(db); Artwork origArtwork = db.Artworks.First(x => x.ID == artwork.ID); //db.Entry(origArtwork).CurrentValues.SetValues(artwork); origArtwork.UpdateFrom(artwork); db.Entry(origArtwork).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(model); }
public void GetArtworkTest() { ArtworkControllerModel target = new ArtworkControllerModel(); // TODO: Initialize to an appropriate value ArtworkDBContext db = null; // TODO: Initialize to an appropriate value Artwork expected = null; // TODO: Initialize to an appropriate value Artwork actual; actual = target.GetArtwork(db); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }