public ActionResult Create(RegionViewModel region)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var entityResult = _placesService.AddRegion(region);

                    if (entityResult.Succeeded)
                    {
                        AddMessageToTempData(CommonResources.SavedSuccessfullyMessage, BusinessSolutions.MVCCommon.MessageType.Success);
                        return(RedirectToAction("Index", new { CountryId = region.CountryId }));
                    }

                    AddValidationErrors(entityResult);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                AddMessageToView(CommonResources.UnExpectedError, BusinessSolutions.MVCCommon.MessageType.Error);
            }

            GetCountries();
            return(View(region));
        }
Exemple #2
0
        public void AddRegion()
        {
            PlaceServiceTestCases.Region = new RegionViewModel
            {
                RegionName = "Region2",
                CountryId  = PlaceServiceTestCases.Country.CountryId,
            };

            _placesServices.AddRegion(PlaceServiceTestCases.Region);

            for (int i = 1; i <= 5; i++)
            {
                var region = new RegionViewModel
                {
                    RegionName = "RegionForIndex" + i,
                    RegionCode = "Code" + i,
                    CountryId  = PlaceServiceTestCases.Country.CountryId,
                };

                var addResult = _placesServices.AddRegion(region);
            }
        }