Esempio n. 1
0
 public void InsertOrUpdate(Cycle cycle)
 {
     if (cycle.Id == default(int)) {
         // New entity
         context.Cycles.Add(cycle);
     } else {
         // Existing entity
         context.Entry(cycle).State = EntityState.Modified;
     }
 }
Esempio n. 2
0
 public ActionResult Create(Cycle cycle)
 {
     if (ModelState.IsValid)
     {
         cycleRepository.InsertOrUpdate(cycle);
         cycleRepository.Save();
         return RedirectToAction("Index");
     }
     else
     {
         return View();
     }
 }