}//morph button event private void addVendor() { if (inputIsValid()) { try { _myVendor.Name = txtVendorName.Text.ToString(); _myVendor.Address = txtVendorAddress.Text; _myVendor.City = txtVendorCity.Text; _myVendor.State = cbVendorState.Text; _myVendor.Country = cbVendorCountry.Text; _myVendor.Zip = txtVendorZipCode.Text; _myVendor.Contact = txtVendorContact.Text; _myVendor.ContactEmail = txtVendorContactEmail.Text; _myVendor.Phone = txtVendorContactPhone.Text; _myVendorManager.AddVendor(_myVendor); MessageBox.Show("Vendor " + _myVendor.Name + " was added."); this.Close(); } catch (Exception ex) { MessageBox.Show("An exception was thrown while adding vendor\n" + ex.ToString()); } } } // end addVendor()
public IHttpActionResult AddVendor(VendorDto vendor) { VendorManager vendorManager = new VendorManager(); string message; if (vendorManager.IsValid(MethodTypes.Post, vendor, out message)) { var newVendor = vendorManager.AddVendor(vendor, out message); if (newVendor != null) { return(Ok(newVendor)); } } return(BadRequest(message)); }