public async Task <IActionResult> Edit(int id, CommonCongregation commonCongregation) { if (id != commonCongregation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(commonCongregation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommonCongregationExists(commonCongregation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["Id"] = new SelectList(_context.City, "Id", "Name", commonCongregation.Id); return(View(commonCongregation)); }
public async Task <IActionResult> Create(CommonCongregationViewModel commonCongregationVM) { var commonCongregation = new CommonCongregation(); if (ModelState.IsValid) { commonCongregation = MapTo(commonCongregationVM); _context.Add(commonCongregation); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CityList = new SelectList(_context.City, "Id", "Name", commonCongregation.Id); return(View(commonCongregation)); }