Exemplo n.º 1
0
 public void InsertOrUpdate(Comment comment)
 {
     if (comment.CommentId == default(System.Guid)) {
         // New entity
         comment.CommentId = Guid.NewGuid();
         context.Comment.Add(comment);
     } else {
         // Existing entity
         context.Entry(comment).State = EntityState.Modified;
     }
 }
Exemplo n.º 2
0
 public ActionResult Create(Comment comment)
 {
     if (ModelState.IsValid) {
         commentRepository.InsertOrUpdate(comment);
         commentRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleTask = taskRepository.All;
         ViewBag.PossibleUser = userRepository.All;
         return View();
     }
 }