예제 #1
0
 public void InsertOrUpdate(Tag tag)
 {
     if (tag.TagId == default(int)) {
         // New entity
         context.Tags.Add(tag);
     } else {
         // Existing entity
         context.Entry(tag).State = EntityState.Modified;
     }
 }
예제 #2
0
 public ActionResult Create(Tag tag)
 {
     if (ModelState.IsValid) {
         tagRepository.InsertOrUpdate(tag);
         tagRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleLinks = linkRepository.All;
         return View();
     }
 }