public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PaymentMethod method = paymentMethodService.Find(id.Value); if (method == null) { return(HttpNotFound()); } var model = Mapper.Map <PaymentMethodViewModel>(method); var countries = method.Countries.ToList(); foreach (var country in countries) { model.CountryCodes.Add(country.Code); } ViewBag.Countries = countryService.FindAll().Where(c => c.IsActive).ToList(); return(View(model)); }