Exemple #1
0
        public IActionResult Index()
        {
            var model = new MenuViewModel()
            {
                Countries = _repository.GetCountries().Select(p => SelectListFactory.Get(p))
            };

            return(View(model));
        }
Exemple #2
0
        public IActionResult AddUpdateCity()
        {
            var model = new MenuViewModel()
            {
                Countries = _repository.GetCountries().Select(p => SelectListFactory.Get(p))
            };

            return(Json(model));
        }
Exemple #3
0
        public async Task <IActionResult> AddUpdateCity(MenuViewModel model)
        {
            if (ModelState.IsValid)
            {
                var city = new City()
                {
                    Description = model.CityName,
                    CountryId   = model.CountryId
                };
                await _repository.Add(city);

                await _repository.Save();

                ModelState.AddModelError("", "City Added Successfully");
            }
            model.Countries = _repository.GetCountries().Select(p => SelectListFactory.Get(p));
            return(View(model));
        }
Exemple #4
0
        public IActionResult GetCountries()
        {
            var countries = _repository.GetCountries().Select(p => SelectListFactory.Get(p));

            return(Json(countries));
        }