Beispiel #1
0
        public void SaveClicked()
        {
            m_view.ReadUserInput();
            Customer      customerDataEntity = m_viewModel.CustomerData;
            List <string> lstMessages        = new List <string>();
            bool          isValid            = m_PersonDao.Validate(customerDataEntity, out lstMessages);

            if (isValid)
            {
                Person mypersonEntity = customerDataEntity as Person;
                if (customerDataEntity.PersonId == 0)
                {
                    m_PersonDao.Insert(mypersonEntity);
                }
                else
                {
                    m_PersonDao.Update(mypersonEntity);
                }
                GetAllCustomer();
            }
            else
            {
                string strMessages = String.Join(Environment.NewLine, lstMessages.Select(a => a.ToString()));
                m_view.Message = strMessages;
                m_view.ShowError();
            }
        }
        public void SaveClicked()
        {
            try
            {
                _view.ReadUserInput();

                ICustomerBO customerDataEntity = _viewModel.CustomerDataEntity;
                bool        duplicateExist     = !IsDuplicateOfExisting(customerDataEntity);
                if (duplicateExist)
                {
                    _service.Save(customerDataEntity);
                    _view.Close();
                }
                else
                {
                    _view.ShowError(string.Format("Customer '{0}' already exist", _viewModel.Name));
                }
            }
            catch (Exception ex)
            {
                _view.ShowError(ex.ToString());
            }
        }