Ejemplo n.º 1
0
        public async Task <ActionResult <ExchangeDetailsModel> > CreateExchangeAsync([FromBody] ExchangeCreateModel exchange)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var createdExchange = await _service.CreateAsync(exchange);

                return(new ObjectResult(createdExchange)
                {
                    StatusCode = 201
                });
            }
            catch (ArgumentException)
            {
                return(BadRequest());
            }
        }