コード例 #1
0
        public IActionResult GetById(int id)
        {
            var User = UserContract.Find(id);

            if (User == null)
            {
                return(new ObjectResult(new User()));
            }
            return(Ok(User));
        }
コード例 #2
0
        public IActionResult Delete(int id)
        {
            //UserRepository.Remove(id);

            var User = UserContract.Find(id);

            if (User == null)
            {
                return(NotFound("User record couldn't be found."));
            }

            UserContract.Remove(id);
            return(NoContent());
        }
コード例 #3
0
        public IActionResult Update(int id, [FromBody] User value)
        {
            if (value is null)
            {
                return(BadRequest("value is null."));
            }

            var User = UserContract.Find(id);

            if (User == null)
            {
                return(NotFound("User record couldn't be found."));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }


            UserContract.Update(value);
            return(new NoContentResult());
        }