Example #1
0
 public ActionResult Create(Link link)
 {
     if (ModelState.IsValid) {
         linkRepository.InsertOrUpdate(link);
         linkRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
Example #2
0
 public void InsertOrUpdate(Link link)
 {
     if (link.LinkId == default(int)) {
         // New entity
         context.Links.Add(link);
     } else {
         // Existing entity
         context.Entry(link).State = EntityState.Modified;
     }
 }