Ejemplo n.º 1
0
        public async Task <ActionResult <Value> > CreateValueAsync([FromBody] Value value)
        {
            var result = await _valueService.AddValueAsync(value);

            if (result == null)
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PostAsync([FromBody] ValueModel valueModel)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(valueModel.Content))
                {
                    return(BadRequest($"{nameof(valueModel.Content)} cannot be null or empty."));
                }

                await _valueService.AddValueAsync(valueModel.Content);

                return(Ok());
            }
            catch (Exception exception)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, exception.Message));
            }
        }