示例#1
0
        private void AddCountry()
        {
            PlaceServiceTestCases.Country = new CountryViewModel
            {
                CountryCode = "00525",
                CountryName = "CountryName",
            };

            var result = _placesServices.AddCountry(PlaceServiceTestCases.Country);
        }
示例#2
0
        public ActionResult Create(CountryViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("InvalidData", CommonResources.InvalidData);
                    return(View(model));
                }

                var result = _placesService.AddCountry(model);
                if (result.Succeeded)
                {
                    AddMessageToTempData(CommonResources.SavedSuccessfullyMessage, BusinessSolutions.MVCCommon.MessageType.Success);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    foreach (var error in result.ValidationErrors)
                    {
                        ModelState.AddModelError(error.Property, error.Message);
                    }

                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                this.Logger.Error(ex);
                AddMessageToView(CommonResources.SavedSuccessfullyMessage, BusinessSolutions.MVCCommon.MessageType.Error);
                return(View(model));
            }
        }