public ActionResult Edit(Post post)
        {
            if (ModelState.IsValid) {
                postRepository.InsertOrUpdate(post);
                postRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
 public void InsertOrUpdate(Post post)
 {
     if (post.Id == default(int)) {
         // New entity
         context.Posts.Add(post);
     } else {
         // Existing entity
         context.Entry(post).State = EntityState.Modified;
     }
 }