Example #1
0
        public async Task <IActionResult> CreateCountry([FromBody] CreateCountryModel createCountryModel)
        {
            CreateCountryDto createCountryDto = _mapper.Map <CreateCountryDto>(createCountryModel);
            await _countryService.CreateCountryAsync(createCountryDto);

            return(Ok());
        }
 public async Task <ActionResult <CountryModel> > Post([FromBody] CreateCountryModel model)
 {
     try
     {
         return(Ok(await this.handler.CreateAsync(model)));
     }
     catch (Exception)
     {
         // here we should capture the custom exception to return the correct response
         throw;
     }
 }
Example #3
0
        public async Task <IActionResult> Post(int organizationId, [FromBody] CreateCountryModel createCountryModel)
        {
            string email = User.Identity.Name;

            await countryService.AddCountryAsync(
                organizationId,
                mapper.Map <CreateCountryModel, CreateCountryDto>(createCountryModel),
                email
                );

            return(Ok());
        }
Example #4
0
        public IHttpActionResult Post([FromBody] CreateCountryModel model)
        {
            var country = new Country
            {
                Name         = model.Name,
                CountryCode1 = model.CountryCode,
                Display      = true
            };

            db.Country.Add(country);
            db.SaveChanges();

            return(Ok(country.Id));
        }