示例#1
0
        public IActionResult Delete(int id)
        {
            StoreDB.User user = _userService.Get(id);
            if (user == null)
            {
                return(NotFound("The User record couldn't be found."));
            }

            _userService.Delete(user);
            return(NoContent());
        }
示例#2
0
        public IActionResult Put(int id, [FromBody] StoreDB.User user)
        {
            if (user == null)
            {
                return(BadRequest("User is null."));
            }

            StoreDB.User userToUpdate = _userService.Get(id);

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

            _userService.Update(userToUpdate, user);
            return(NoContent());
        }
示例#3
0
        public IActionResult Post([FromBody] StoreDB.User value)
        {
            if (value == null)
            {
                return(BadRequest("user is null"));
            }

            try
            {
                _userService.Add(value);
                return(CreatedAtRoute("Get",
                                      new { Id = value.UserId },
                                      value));
            }
            catch (Exception ex)
            {
                return(BadRequest("user no saved => " + ex.Message));
            }
        }