public async Task <IActionResult> Post([FromBody] Product product) { try { await _context.AddAsync(product); var saved = await _context.SaveChangesAsync(); if (saved > 0) { return(CreatedAtAction(nameof(GetProduct), new { id = product.Id }, product)); } return(BadRequest()); } catch (Exception exception) { return(BadRequest(exception)); } }