public HttpResponseMessage Post(CustomerDTO customerDTO) { try { if (customerDTO == null) { return(null); } if (customerDTO.ID > 0) { return(_httpResponseMessageBuilder.GetSimpleResponse(_customerBL.Update(customerDTO), Request)); } return(_httpResponseMessageBuilder.GetSimpleResponse(_customerBL.Add(customerDTO), Request)); } catch (System.Exception ex) { ExceptionHandler exceptionHandler = new ExceptionHandler(); exceptionHandler.WrapLogException(ex); return(null); } }
private void RegisterCustomerRadButton_Click(object sender, EventArgs e) { if (ValidateComponent()) { if (this._stateForm == StateForm.NEW) { #region Create a New Customer Customer _customerNew = Customer.CreateNewInstance(); _customerNew.CustomerCode = CustomerCodeRadTextBox.Text; _customerNew.CompanyName = CompanyNameRadTextBox.Text; _customerNew.Email = EmailRadTextBox.Text; _customerNew.ContactName = ContactNameRadTextBox.Text; _customerNew.DocumentID = DocumentIDRadTextBox.Value.ToString(); _customerNew.Address1 = Address1RadTextBox.Text; _customerNew.Address2 = Address2RadTextBox.Text; _customerNew.Phone1 = Phone1RadMaskedEditBox.Value.ToString(); _customerNew.Cellphone = CellphoneRadMaskedEditBox.Value.ToString(); _customerNew.BusinessRegistration = BusinessRegistrationRadTextBox.Text; _customerNew.TaxRegistration = TaxRegistrationRadTextBox.Text; _customerNew.State = (CustomerState)Enum.ToObject(typeof(CustomerState), (int)StateComboBox.SelectedValue); _customerNew.ProvinceID = (int)ProvinceIDComboBox.SelectedValue;; _customerNew.MunicipalityID = (int)MunicipalityIDComboBox.SelectedValue; _customerNew.DateAdmission = DateAdmissionRadDateTimePicker.Value; _customerNew.Birthday = BirthdayRadDateTimePicker.Value; #endregion try { _serviceCustomer.Add(_customerNew); RadMessageBox.Show(null, "Cliente registrado satisfactoriamente", "JOSIAS INDUSTRIAL SRL", MessageBoxButtons.OK, RadMessageIcon.Info); ClearForm(); _currentParentForm.FillCustomersRadGridView(); } catch (Exception ee) { //RadMessageBox.Show("Cliente registrado", "JOSIAS INDUSTRIAL SRL", MessageBoxButtons.AbortRetryIgnore, " Sistema prueba"); MessageBox.Show(ee.Message); } } else if (this._stateForm == StateForm.EDIT) { #region Update a Customer CustomerToEdit.CustomerCode = CustomerCodeRadTextBox.Text; CustomerToEdit.CompanyName = CompanyNameRadTextBox.Text; CustomerToEdit.Email = EmailRadTextBox.Text; CustomerToEdit.ContactName = ContactNameRadTextBox.Text; CustomerToEdit.DocumentID = DocumentIDRadTextBox.Value.ToString(); CustomerToEdit.Address1 = Address1RadTextBox.Text; CustomerToEdit.Address2 = Address2RadTextBox.Text; CustomerToEdit.Phone1 = Phone1RadMaskedEditBox.Value.ToString(); CustomerToEdit.Cellphone = CellphoneRadMaskedEditBox.Value.ToString(); CustomerToEdit.BusinessRegistration = BusinessRegistrationRadTextBox.Text; CustomerToEdit.TaxRegistration = TaxRegistrationRadTextBox.Text; CustomerToEdit.State = (CustomerState)Enum.ToObject(typeof(CustomerState), (int)StateComboBox.SelectedValue); CustomerToEdit.ProvinceID = (int)ProvinceIDComboBox.SelectedValue;; CustomerToEdit.MunicipalityID = (int)MunicipalityIDComboBox.SelectedValue; CustomerToEdit.DateAdmission = DateAdmissionRadDateTimePicker.Value; CustomerToEdit.Birthday = BirthdayRadDateTimePicker.Value; #endregion try { _serviceCustomer.Update(CustomerToEdit); RadMessageBox.Show(null, "Cliente actualizado satisfactoriamente", "JOSIAS INDUSTRIAL SRL", MessageBoxButtons.OK, RadMessageIcon.Info); CustomerToEdit = null; ClearForm(); _currentParentForm.FillCustomersRadGridView(); } catch (Exception ee) { RadMessageBox.Show(ee.Message, "JOSIAS INDUSTRIAL SRL", MessageBoxButtons.OK, RadMessageIcon.Error, ee.StackTrace); } } } }