Пример #1
0
        public async Task <ActionResult> AddCountry(CountryAddModel Country)
        {
            if (ModelState.IsValid)
            {
                await CountryService.Add(Country);

                return(RedirectToAction("Index"));
            }
            return(View("Add"));
        }
Пример #2
0
        public async Task <IHttpActionResult> AddCountry(CountryAddModel country)
        {
            if (!ModelState.IsValid)
            {
                return(this.InternalServerError());
            }
            try
            {
                await services.Add(country);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Пример #3
0
        public async Task <ActionResult <Country> > PostCountry(Country country)
        {
            await services.Add(country);

            return(CreatedAtAction("GetCountry", new { id = country.Id }, country));
        }