public ActionResult Create(TypeRating typerating)
 {
     if (ModelState.IsValid) {
         typeratingRepository.InsertOrUpdate(typerating);
         typeratingRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
 public void InsertOrUpdate(TypeRating typerating)
 {
     if (typerating.ID == default(int)) {
         // New entity
         context.TypeRating.Add(typerating);
     } else {
         // Existing entity
         context.TypeRating.Attach(typerating);
         context.Entry(typerating).State = EntityState.Modified;
     }
 }