public IActionResult PostContents(FridgeItem item)
        {
            _fridge.AddItem(item);

            //if (success)
            //{
            return(CreatedAtAction(nameof(GetContentsById), new { item.ID }, value: item));
            //}
            //ModelState.AddModelError(nameof(item.ID));
            //return BadRequest();
        }
예제 #2
0
 public IActionResult PostContents(FridgeItem item)
 {
     _fridge.AddItem(item);
     return(CreatedAtAction(
                actionName: nameof(GetContentsById),
                routeValues: new { item.Id },
                value: item));
     // if there was a validation error we caught here...
     //ModelState.AddModelError(nameof(item.Id))
     //return BadRequest(;
 }
        public IActionResult PostContents(FridgeItem item)
        {
            var success = _fridge.AddItem(item);

            if (success)
            {
                return(CreatedAtAction(
                           actionName: nameof(GetContentsById),
                           routeValues: new { item.Id },
                           value: item));
            }
            // if there was a validation error caught here...
            ModelState.AddModelError("", "");
            return(BadRequest());
        }