public string AddItem(ItemModel aAddItem) { if (addItem.IsExistsItem(aAddItem)) { return("Item Name Already Exist,Please Input Another Company"); } else { int rowAffect = addItem.AddItem(aAddItem); if (rowAffect == 1) { return("Item Added Successfully"); } else { return("Item Added Successfully"); } } }
public async Task Can_Create_Update_Delete_Find_Item() { ItemGateway gateway = new ItemGateway(TestHelpers.ConnectionString); string itemName = TestHelpers.RandomTestName(); int unitPrice = 1025; var itemResult = await gateway.AddItem(itemName, unitPrice); Assert.That(itemResult.Status, Is.EqualTo(Status.Created)); int itemId = itemResult.Content; Result <Item> item; { item = await gateway.FindItemById(itemId); CheckItem(item, itemName, unitPrice); } { itemName = TestHelpers.RandomTestName(); unitPrice = 525; await gateway.UpdateItem(itemId, itemName, unitPrice); item = await gateway.FindItemById(itemId); CheckItem(item, itemName, unitPrice); } { int row = await gateway.DeleteItem(itemId); Assert.That(row, Is.EqualTo(1)); item = await gateway.FindItemById(itemId); Assert.That(item.Status, Is.EqualTo(Status.NotFound)); } }