public ActionResult Create(MedicType medictype) { if (ModelState.IsValid) { medictypeRepository.InsertOrUpdate(medictype); medictypeRepository.Save(); return RedirectToAction("Index"); } else { return View(); } }
public void InsertOrUpdate(MedicType medictype) { if (medictype.medicTypeID == default(int)) { // New entity context.MedicTypes.Add(medictype); } else { // Existing entity context.Entry(medictype).State = EntityState.Modified; } }