Пример #1
0
        public ActionResult Create(PersonViewmodel person)
        {
            try
            {
                // TODO: Add insert logic here

                Person Person = new Person();

                if (ModelState.IsValid)
                {
                    Person.Name = person.Name;
                    // Person.Country.CountryId = person.Country.CountryId;
                    Person.CityId = person.CityId;
                    db.People.Add(Person);
                    db.SaveChanges();
                    //ViewBag.CountryName = new SelectList(db.Countries, "CountryId", "ContryName").ToList();
                    return(RedirectToAction("Index"));
                }
                return(View(person));
            }
            catch
            {
                return(View(person));
            }
        }
Пример #2
0
        public ActionResult Create()
        {
            PersonViewmodel vm = new PersonViewmodel();

            vm.Countrys = db.Countries.Include("cities").ToList();
            //ViewBag.CountryId= new SelectList(db.Countries, "CountryId", "ContryName").ToList();

            return(View(vm));
        }