public ActionResult Create(CountryCreateModel model) { if (ModelState.IsValid) { try { var country = new Country() { CountryCode = model.CountryCode, CountryOrder = model.CountryOrder, CountryName = model.CountryName, Displayable = model.Displayable ? "1" : "0" }; country = CountriesService.Create(country); this.FlashInfo(string.Format("Country {0} was created succcessfully", country.CountryName)); return RedirectToAction("Index"); } catch (ErrorException errorException) { errorException.ToModelState(this); return View(model); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return View(model); } } return View(model); }
public ActionResult Create() { var numberOfCountries = CountriesService.GetAll().Count(); var model = new CountryCreateModel(numberOfCountries); return View(model); }