コード例 #1
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid) {
         userRepository.InsertOrUpdate(user);
         userRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleCountry = countryRepository.All;
         ViewBag.PossibleRank = rankRepository.All;
         ViewBag.PossibleAirport = airportRepository.All;
         return View();
     }
 }
コード例 #2
0
 private bool ValidateNumberOfTyperatingsInternal(int selectedAicraftTypes, User userToCheck)
 {
     return selectedAicraftTypes <= userToCheck.Rank.NumberOfTyperatings && selectedAicraftTypes > 0;
 }
コード例 #3
0
 public void InsertOrUpdate(User user)
 {
     if (user.ID == default(int)) {
         // New entity
         context.User.Add(user);
     } else {
         // Existing entity
         context.User.Attach(user);
         context.Entry(user).State = EntityState.Modified;
     }
 }