コード例 #1
0
        public IActionResult Create([FromBody] Library item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            var createdLibrary = _libraryRepository.Add(item);

            if (createdLibrary == null)
            {
                return(Ok("Book doesn't exist!"));
            }

            return(CreatedAtRoute("GetLibrary", new { id = createdLibrary.libraryid }, createdLibrary));
        }
コード例 #2
0
        public IActionResult Create([FromBody] MyLibrary item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            MyLibrary lastItem = libraryRepository.Add(item);

            if (lastItem == null)
            {
                return(StatusCode(500, "Could not add last item successfully. Please try again."));
            }
            long newID = lastItem.libraryid;

            return(CreatedAtRoute("GetLibrary", new { idLibrary = newID }, lastItem));
        }