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(); } }
private bool ValidateNumberOfTyperatingsInternal(int selectedAicraftTypes, User userToCheck) { return selectedAicraftTypes <= userToCheck.Rank.NumberOfTyperatings && selectedAicraftTypes > 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; } }