Пример #1
0
        public City Add(CreateCity createCity)              // CreateCity is the class, createCity is the ViewModel
        {
            City city = new City();                         // A "blank" city is created

            city.CityName = createCity.CityName;            // In this section add additional validations and checks
            // city.PersonInQuestion = _peopleRepo.Read(createCity.PersonInQuestionId);    // Using peopleRepo and the PersonInQuestionId to put in the right city based on the Id
            city.Country = _countryRepo.Read(createCity.CountryId);
            return(_cityRepo.Create(city));
        }
Пример #2
0
        public City Add(CreateCity createCity)
        {
            City city = new City();

            city.CityName = createCity.CityName;
            city.Country  = _countryRepo.Read(createCity.CountryId);

            return(_cityRepo.Create(city));
        }
Пример #3
0
        public City Add(CreateCityViewModel createCity)
        {
            City city = new City();

            city.CityName           = createCity.cityName;
            city.CountryNationsName = _countryRepo.Read(createCity.NationsId);

            city = _cityRepo.Create(city);

            return(city);
        }
Пример #4
0
        public City Add(CreateCityViewModel createCityViewModel)
        {
            List <Person> personInCity = new List <Person>();

            foreach (int personID in createCityViewModel.PeopleID)
            {
                Person person = _peopleRepo.Read(personID);
                personInCity.Add(person);
            }


            City city = _cityRepo.Create(personInCity, createCityViewModel.States, createCityViewModel.CityName);

            return(city);
        }
Пример #5
0
        public City Add(CreateCityViewModel createCity)
        {
            //create city
            City city = new City();

            city.Name   = createCity.Name;
            city.Nation = _countryRepo.Read(createCity.NationId);
            city        = _cityRepo.Create(city);

            //update Country with city  --should not be needed
            //Country countryToUpdate = _countryRepo.Read(city.Nation.Id);
            //if (countryToUpdate != null)
            //{
            //    _countryRepo.Read(createCity.NationId).Cities.Add(city);
            //}
            return(city);
        }
        public IActionResult Create(CityAddVM model)
        {
            if (ModelState.IsValid)
            {
                var country = _cityRepos.GetAll().FirstOrDefault(c => c.Name == model.Name);
                if (country == null)
                {
                    var result = _cityRepos.Create
                                     (new City
                    {
                        Name       = model.Name,
                        CountryId  = model.CountryId,
                        DateCreate = DateTime.Now
                    });
                }

                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Дані вказано не коректно");
            return(View(model));
        }
Пример #7
0
        public City Add(CreateCityViewModel createCityViewModel)
        {
            /*if (_cityService.FindBy(createCityViewModel.cityList) == null)
             * {
             *  return null;
             * }*/

            List <Person> personInCity = new List <Person>();

            foreach (int personID in createCityViewModel.PeopleID)
            {
                Person person = _peopleRepo.Read(personID);
                personInCity.Add(person);
            }

            //Person person = _peopleRepo.Read(createCityViewModel.PersonID);
            //City city = _cityRepo.Create(person, createCityViewModel.States, createCityViewModel.CityName);

            City city = _cityRepo.Create(personInCity, createCityViewModel.States, createCityViewModel.CityName);

            return(city);
        }
Пример #8
0
 public void AddCity(Models.City city)
 {
     cityRepo.Create(city);
 }
Пример #9
0
 public City Add(CreateCityViewModel createCityViewModel)
 {
     return(_cityRepo.Create(createCityViewModel.CityName, createCityViewModel.Country));
 }