Beispiel #1
0
        public IActionResult CreateNewNewsItem([FromBody] NewsItemInputModel body)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model is not properly formatted."));
            }
            var entity = _newsItemService.CreateNewNewsItem(body);

            return(CreatedAtRoute("getNewsItemById", new { id = entity.Id }, null));
        }
        public IActionResult CreateNewNewsItem([FromBody] NewsItemInputModel body)
        {
            if (!_authenticationService.isValidToken(Request.Headers["Authorization"]))
            {
                return(Unauthorized());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model is not properly formatted."));
            }

            var entity = _newsItemService.CreateNewNewsItem(body);

            return(CreatedAtRoute("GetNewsById", new { id = entity.Id }, null));
        }
        public IActionResult CreateNewNewsItem([FromBody] NewsItemInputModel item)
        {
            if (!ModelState.IsValid)
            {
                return(StatusCode(412, item));
            }
            var lang = Request.Headers["Authorization"];

            if (lang == "key")
            {
                var id = _newsItemService.CreateNewNewsItem(item);
                return(CreatedAtRoute("GetNewsItemById", new { id }, null));
            }
            else
            {
                return(StatusCode(401, "Key is unauthorized"));
            }
        }