Ejemplo n.º 1
0
        public IActionResult MultipleAreas(MultiplAreaViewModel model)
        {
            var areaList = strSplitter.SendTArray(model.MultipleAreas);

            foreach (var item in areaList)
            {
                var newArea = new ElectionArea();
                newArea.IsActive = true;
                newArea.Name     = item.Name;
                newArea.CityId   = model.CityId;
                int result = areaRepo.Create(newArea);
            }
            return(RedirectToAction("MapAreas", new { CityId = model.CityId, CityName = model.CityName }));
        }
Ejemplo n.º 2
0
        public IActionResult MultipleCities(MultipleCitiesViewModel model)
        {
            var cList = strSplitter.SendTArray(model.CityList);

            foreach (var item in cList)
            {
                var newCity = new City();
                newCity.IsActive   = true;
                newCity.Name       = item.Name;
                newCity.DistrictId = model.DistrictId;
                int result = cityrepo.Create(newCity);
            }
            return(RedirectToAction("MapCities", new { DistrictId = model.DistrictId, DistrictName = model.DistrictName }));
        }
Ejemplo n.º 3
0
        public IActionResult MultipleDistricts(DistrictMultipleCreateViewModel model)
        {
            var districtlist = strSplitter.SendTArray(model.MultipleDistricts);


            foreach (var item in districtlist)
            {
                var dis = new Districts();
                dis.Name = item.Name;

                dis.IsActive = item.IsActive;
                dis.StateId  = model.InitialStateId;
                int result = _distrepo.Create(dis);
            }

            return(RedirectToAction("MapDistricts", new { StateId = model.InitialStateId, StateName = model.InitialStateName }));
        }
        public IActionResult MultipleStates(MultipleStatesViewModel model)
        {
            var cid   = Convert.ToInt32(model.CountryId);
            var cname = model.CountryName;

            if (model is null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (cname == null)
            {
                throw new Exception("Countryname can not be null");
            }
            if (cid == null)
            {
                throw new Exception("cid can not be null");
            }
            List <string> messages   = new List <string>();
            var           state      = model.StateList;
            var           splitState = strSplitter.SendTArray(state);


            foreach (var item in splitState)
            {
                States sts = new States {
                    Name = item.Name, IsActive = item.IsActive, CountryId = cid, IsUT = item.IsUT
                };

                int result = stateRepo.Create(sts);
                if (result > 0)
                {
                    messages.Add($"{item.Name} Added successfully");
                }
                else
                {
                    messages.Add($"Adding {item.Name} failed");
                }
            }

            return(RedirectToAction("MapStatesToCountry", new { countryid = cid, countryname = cname }));
        }