コード例 #1
0
        public async Task <IActionResult> Add(InputCountryViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }
            var result = await this._countriesService.Add(model);

            this.TempData[GlobalConstants.SuccessMessageKey] = $"{model.Name}" + GlobalConstants.SuccessfullyAddedMessage;
            return(this.Redirect("Add"));
        }
コード例 #2
0
        public async Task <int> Add(InputCountryViewModel model)
        {
            var country = new Country
            {
                Name = model.Name,
            };

            await this._countryRepository.AddAsync(country);

            var result = await this._countryRepository.SaveChangesAsync();

            return(result);
        }