public IActionResult CreateNewNews([FromBody] NewsItemInputModel news) { if (ModelState.IsValid) { var id = _newsService.CreateNewNews(news); return(CreatedAtRoute("GetNewsById", new { id }, null)); } return(StatusCode(412, news)); }
public IActionResult CreateNewNews([FromHeader] string AuthorizedCode, [FromBody] NewsItemInputModel body) { if (AuthorizedCode == null || AuthorizedCode != _password) { return(StatusCode(403)); } if (!ModelState.IsValid) { return(BadRequest("input model not valid")); } var news = _newsService.CreateNewNews(body); return(CreatedAtRoute("GetNewsById", new { id = news.Id }, null)); }