public ActionResult Create(PlaygroundImage playgroundimage) { if (ModelState.IsValid) { playgroundimageRepository.InsertOrUpdate(playgroundimage); playgroundimageRepository.Save(); return RedirectToAction("Index"); } else { ViewBag.PossiblePlaygrounds = playgroundRepository.All; return View(); } }
public void InsertOrUpdate(PlaygroundImage playgroundimage) { if (playgroundimage.PlaygroundImageId == default(int)) { // New entity context.PlaygroundImages.Add(playgroundimage); } else { // Existing entity context.Entry(playgroundimage).State = EntityState.Modified; } }