コード例 #1
0
        public ApiResponse <IEnumerable <InventoryItem> > AddUpdate([FromBody] InventoryItem item)
        {
            item.LastUpdated = DateTime.Now;
            var existing = _context.Find <InventoryItem>(new object[] { item.ProductId });

            if (existing == null)
            {
                _context.Add(item);
            }
            else
            {
                existing.Quantity = item.Quantity;
            }
            _context.SaveChanges();
            return(GetAll());
        }