public ActionResult Create(Webpage webpage)
 {
     if (ModelState.IsValid) {
         webpageRepository.InsertOrUpdate(webpage);
         webpageRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
 public void InsertOrUpdate(Webpage webpage)
 {
     if (webpage.Id == default(int)) {
         // New entity
         context.Webpages.Add(webpage);
     } else {
         // Existing entity
         context.Webpages.Attach(webpage);
         context.Entry(webpage).State = EntityState.Modified;
     }
 }