private async void btmAddItem_Click(object sender, System.EventArgs e) { ItemModel output = null; if (!validateData()) { return; } if (_editing) { _editingItem.Name = textBoxName.Text; _editingItem.Price = decimal.Parse(textBoxPrice.Text); _editingItem.Description = textBoxDesc.Text; _editingItem.Owner = (VendorModel)listBoxVendors.SelectedItem; _editingItem.OwnerId = _editingItem.Owner.Id; _editingItem.Sold = checkBoxSold.Checked; _editingItem.PaymentDistributed = checkBoxVendorPaid.Checked; _itemData.UpdateItem(_editingItem); btnAddItem.Text = "Add Item"; btnEdit.Enabled = true; _editing = false; output = _editingItem; } else { output = new ItemModel() { Name = textBoxName.Text, Price = decimal.Parse(textBoxPrice.Text), Description = textBoxDesc.Text, Owner = (VendorModel)listBoxVendors.SelectedItem, Sold = checkBoxSold.Checked }; await _itemData.CreateItem(output); } UpdateItems(); ClearItemInput(); }
public async Task <IActionResult> Post(ItemModel itemModel) { int id = await _itemData.CreateItem(itemModel); return(Ok(new { Id = id })); }