private async void Save() { try { var purchaseProduct = new PurchaseProductModel(); purchaseProduct.PurchaseProductID = _purchaseProductID; purchaseProduct.ProductID = _productID; purchaseProduct.Quantity = txtQuantity.Text.ToInt(); //purchaseProduct.IsQuantityUploaded = chkUploadQuantity.Checked; purchaseProduct.UnitCost = txtPrice.Text.ToDecimal(); if (_purchaseProductID > 0) { // edit await _purchaseService.EditPurchaseProduct(purchaseProduct); } else { // add await _purchaseService.AddPurchaseProductAsync(_purchaseID, purchaseProduct); } this.Close(); } catch (CustomBaseException ex) { MetroMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MetroMessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }