public async Task Add_item_to_catalog_should_return_added_item() { //Arrange var item = CreateCatalogItem(); //Act var result = await _repository.AddItemAsync(item); //Assert Assert.NotNull(result); Assert.True(result.Id > 0, "The newly added Id is not larger than 0!"); }
public async Task <IActionResult> CreateProduct([FromBody] CatalogItem product) { try { var result = await _repository.AddItemAsync(product); if (result == null) { return(BadRequest()); } return(CreatedAtAction(nameof(GetById), new { id = result.Id }, null)); } catch (Exception ex) { _logger.Debug(ex.Message); return(StatusCode((int)HttpStatusCode.InternalServerError)); } }