public ActionResult Insert(Country country) { if (ModelState.IsValid) { countryRepository.Save(country); return RedirectToAction("List"); } return View(country); }
public void Save(Country country) { if ((country.Id == null) || (country.Id == Guid.Empty)) { country.Id = Guid.NewGuid(); Context.Country.Add(country); } else { var existing_hotel = Context.Country.First(x => x.Id == country.Id); if (existing_hotel != null) { existing_hotel.Name = country.Name; //Add more mapping } } Context.SaveChanges(); }