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()); }
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()); }