Ejemplo n.º 1
0
        public async Task <ActionResult> AddANewsItem(NewsPostDto newsInput)
        {
            if (!ModelState.IsValid)
            {
                _logger.LogWarning("In cnews controller,  addnews item model invalid");
                return(BadRequest(ModelState));
            }

            var num = await _newsRepo.AddANewsItem(newsInput);

            if (num < 1)
            {
                _logger.LogError("In cnews controller, nothing returned from repo add-news item");
                return(BadRequest("The News item was not added."));
            }
            var confirm = _conf.ConfirmResponse(true, "A News item has been added successfully.");

            return(Ok(confirm));
        }