コード例 #1
0
ファイル: USERRepository.cs プロジェクト: jvii05/Prototipo
 public void InsertOrUpdate(USER user)
 {
     if (user.ID == default(decimal)) {
         // New entity
         context.USERs.Add(user);
     } else {
         // Existing entity
         context.Entry(user).State = EntityState.Modified;
     }
 }
コード例 #2
0
ファイル: UsersController.cs プロジェクト: jvii05/Prototipo
 public ActionResult Create(USER user)
 {
     if (ModelState.IsValid) {
         userRepository.InsertOrUpdate(user);
         userRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }