Exemplo n.º 1
0
        public async Task <ActionResult> AddCountry(CountryAddModel Country)
        {
            if (ModelState.IsValid)
            {
                await CountryService.Add(Country);

                return(RedirectToAction("Index"));
            }
            return(View("Add"));
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult <Country> > PostCountry(Country country)
        {
            await services.Add(country);

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