コード例 #1
0
ファイル: PriceController.cs プロジェクト: M4ntha5/kika-group
        public async Task <IActionResult> Post(string sku, [Required, FromBody] InsertPrice insertPrice)
        {
            if (insertPrice == null || decimal.Parse(insertPrice.Price) < 1 || string.IsNullOrEmpty(sku))
            {
                throw new Exception("Invalid information entered");
            }

            await _priceService.InsertPrice(sku, insertPrice);

            await _context.SaveChangesAsync();

            return(Ok());
        }
コード例 #2
0
ファイル: ItemsController.cs プロジェクト: M4ntha5/kika-group
        public async Task <IActionResult> Post([Required, FromBody] UpdateItem newItem)
        {
            if (newItem == null || string.IsNullOrEmpty(newItem.Ean) || string.IsNullOrEmpty(newItem.Sku) ||
                string.IsNullOrEmpty(newItem.Name))
            {
                throw new Exception("Some fields are missing");
            }

            await _itemService.InsertItem(newItem);

            await _context.SaveChangesAsync();

            return(Ok());
        }