public Country Add(CreateCountryViewModel createCountry)
        {
            Country country = new Country();

            country.Name   = createCountry.Name;
            country.Cities = createCountry.CityList;
            return(_countryRepo.Create(country));
        }
        public Country Add(CreateCountry CreateCountry)
        {
            Country country = new Country();

            country.CountryName = CreateCountry.CountryName;

            return(_countryRepo.Create(country));
        }
        public Country Add(CreateCountry createCountry)
        {
            Country city = new Country();

            city.CountryName = createCountry.CountryName;


            return(_countryRepo.Create(city));
        }
Exemple #4
0
        public Country Add(CreateCountryViewModel createCountryViewModel)
        {
            List <City> cityInCountry = new List <City>();

            foreach (int cityID in createCountryViewModel.ListCityID)
            {
                City city = _cityRepo.Read(cityID);
                cityInCountry.Add(city);
            }


            Country country = _countryRepo.Create(cityInCountry, createCountryViewModel.CountryName);

            return(country);
        }
Exemple #5
0
        public async Task <IActionResult> CreateAsync(CountryAddVM model)
        {
            if (ModelState.IsValid)
            {
                var serverPath = _env.ContentRootPath; //Directory.GetCurrentDirectory(); //_env.WebRootPath;
                var folerName  = @"\wwwroot\Uploads\";
                //var path = Path.Combine(serverPath, folerName); //
                var path = serverPath + folerName; //
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string ext      = Path.GetExtension(model.Flag.FileName);
                string fileName = Path.GetRandomFileName() + ext;

                string filePathSave = Path.Combine(path, fileName);

                // сохраняем файл в папку Files в каталоге wwwroot
                using (var fileStream = new FileStream(filePathSave, FileMode.Create))
                {
                    await model.Flag.CopyToAsync(fileStream);
                }

                var country = _countryRepos.GetAll().FirstOrDefault(c => c.Name == model.Name);
                if (country == null)
                {
                    var result = _countryRepos.Create
                                     (new Country
                    {
                        Name       = model.Name,
                        Flag       = fileName,
                        DateCreate = DateTime.Now
                    });
                }

                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Дані вказано не коректно");
            return(View(model));
        }
Exemple #6
0
 public Country Add(CreateCountryViewModel createCountryViewModel)
 {
     return(_countryRepo.Create(createCountryViewModel.CountryName));
 }
Exemple #7
0
 public Country Add(CountryCreateModel newCountryModel)
 {
     return(_countryRepo.Create(newCountryModel.Name));
 }