public void InsertOrUpdate(Log4Net log4Net) { if (log4Net.ID == default(int)) { // New entity _context.Log4Net.Add(log4Net); } else { // Existing entity _context.Entry(log4Net).State = EntityState.Modified; } }
public ActionResult Create(Log4Net log4net) { if (!ModelState.IsValid) { return View(); } _log4NetRepository.InsertOrUpdate(log4net); _log4NetRepository.Save(); return RedirectToAction("Index"); }