Ejemplo n.º 1
0
        public async Task <ActionResult> Post([FromBody] MedicamentoEntity medicamento)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var result = await _service.Post(medicamento);

                if (result != null)
                {
                    return(Created(new Uri(Url.Link("GetWithId", new { id = result.Id })), result));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (ArgumentException e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
            }
        }