Пример #1
0
        public void A050_SaveNewCountry()
        {
            Country country = new Country("", country6Description, country6RegionKey);

            countriesService.Save(ref country);

            country6Key = country.PrimaryKey;
        }
        public ActionResult Edit()
        {
            CountriesService countriesService = new CountriesService();

            CountriesEditVM model = new CountriesEditVM();
            TryUpdateModel(model);

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            Country country;
            if (model.ID == 0)
            {
                country = new Country();
            }
            else
            {
                country = countriesService.GetByID(model.ID);
                if (country == null)
                {
                    return RedirectToAction("List");
                }
            }

            country.ID = model.ID;
            country.Name = model.Name;
            country.Population = model.Population;
            country.FoundationDate = model.FoundationDate;

            countriesService.Save(country);

            return RedirectToAction("List");
        }