private CommonCongregation MapTo(CommonCongregationViewModel commonCongregationVM) { return(new CommonCongregation() { IdCity = commonCongregationVM.IdCity, Name = commonCongregationVM.Name, Address = commonCongregationVM.Address, District = commonCongregationVM.District, FaxPhoneNumber = commonCongregationVM.FaxPhoneNumber, PhoneNumber = commonCongregationVM.PhoneNumber, ZipCode = commonCongregationVM.ZipCode }); }
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)); }