public IActionResult AddItem(Item item, int stockId) { var currentUserId = int.Parse(User.Identity.Name); var newItem = _itemsService.AddItem(item, stockId, currentUserId); return(Ok(newItem)); }
public IActionResult AddItem(ItemsModel model) { int status = _itemRepository.AddItem(model); if (status > 0) { return(Ok(model)); } else if (status == -1) { return(Conflict(new { message = "Item name already exists." })); } else { return(BadRequest(new { message = "Item not added to cart. Please try again!" })); } }