//[ValidateAntiForgeryToken] public ActionResult Create(Church church) { if (!ModelState.IsValid) { var viewModel = new NewChurchViewModel { Church = church, //MembershipTypes = _context.MembershipTypes.ToList() }; return(View("ChurchForm", viewModel)); } if (church.Id == 0) { _context.churches.Add(church); } else { var churchInDb = _context.churches.Single(c => c.Id == church.Id); churchInDb.Name = church.Name; } _context.SaveChanges(); return(RedirectToAction("Index", "Church")); // return View(); }
public ActionResult New() { var provinces = _context.Provinces.ToList(); var ViewModel = new NewChurchViewModel { Provinces = provinces }; return(View("ChurchForm", ViewModel)); }
public ActionResult Edit(int id) { var church = _context.churches.SingleOrDefault(c => c.Id == id); if (church == null) { return(HttpNotFound()); } var viewModel = new NewChurchViewModel { Church = church, //MembershipTypes = _context.MembershipTypes.ToList() }; return(View("ChurchForm", viewModel)); }