예제 #1
0
 public void InsertOrUpdate(User user)
 {
     if (user.Id == default(int)) {
         // New entity
         context.Users.Add(user);
     } else {
         // Existing entity
         context.Entry(user).State = EntityState.Modified;
     }
 }
예제 #2
0
 public JsonResult Create(User userIn)
 {
     if (ModelState.IsValid) {
         userRepository.InsertOrUpdate(userIn);
         userRepository.Save();
     //                return RedirectToAction("Index");
     }
     //else {
     ////			}
     return Json(userRepository.AllIncluding(user => user.UserLocations, user => user.UserRoles), JsonRequestBehavior.AllowGet);
 }