Example #1
0
        public void TestMethod1()
        {
            //Arrange
            CustomerMapper.InitializeCustomerMapper();
            var customerServiceMock    = A.Fake <ICustomerService>();
            var customerRepositoryMock = A.Fake <ICustomerRepository>();
            //var customerController = new CustomerController(customerServiceMock);

            var customerController = new CustomerController(new CustomerService(new CustomerRepository()));

            //Act
            var response = customerController.AddNewCustomer(CustomerBuilder.BuildCustomer());

            //Assert
            Assert.AreEqual(response.StatusCode, ResponseCodes.Ok);
        }
 private void BtSaveForm_Click(object sender, RoutedEventArgs e)
 {
     if (LblCustomerId.Content == null) //Is this a new Customer?
     {
         if (MessageBox.Show($"Create new Customer {TbCusFirstName.Text} {TbCusLastName.Text}?", "Create New", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             cusControl.AddNewCustomer(this);                            //Add new Customer
             LbCustomerList.ItemsSource = cusControl.FillCustomerList(); //Rebuild list
         }
     }
     else //Existing Customer
     {
         if (MessageBox.Show($"Create new Customer {TbCusFirstName.Text} {TbCusLastName.Text}?", "Create New", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             cusControl.UpdateCustomer(this);                            //Update Customer record
             LbCustomerList.ItemsSource = cusControl.FillCustomerList(); //Rebuild list
         }
     }
 }
Example #3
0
        private void Register_Button_Click(object sender, EventArgs e)
        {
            if (User_Type == "Customer")
            {
                CustomerModel NewCustomer = new CustomerModel();
                NewCustomer.User_Name   = UserName_TextBox.Text;
                NewCustomer.First_Name  = FirstName_TextBox.Text;
                NewCustomer.Second_Name = SecondName_TextBox.Text;
                NewCustomer.Email       = Email_TextBox.Text;
                NewCustomer.Password    = Password_TextBox.Text;
                if (Male_RadioButton.Checked)
                {
                    NewCustomer.Gender = "Male";
                }
                else
                {
                    NewCustomer.Gender = "Female";
                }
                NewCustomer.Birth_Date = BirthDate_Time.Value;
                NewCustomer.Country    = Country_TextBox.Text;


                CustomerController Control = new CustomerController();

                bool IsAdded = Control.AddNewCustomer(NewCustomer);

                if (IsAdded)
                {
                    MessageBox.Show(Control.Message, "Information", MessageBoxButtons.OK);
                    this.Close();
                }
                else
                {
                    if (MessageBox.Show(Control.Message, "Error", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
                    {
                        this.Close();
                    }
                }
            }
            else
            {
                AdminModel NewAdmin = new AdminModel();
                NewAdmin.User_Name   = UserName_TextBox.Text;
                NewAdmin.First_Name  = FirstName_TextBox.Text;
                NewAdmin.Second_Name = SecondName_TextBox.Text;
                NewAdmin.Email       = Email_TextBox.Text;
                NewAdmin.Password    = Password_TextBox.Text;
                if (Male_RadioButton.Checked)
                {
                    NewAdmin.Gender = "Male";
                }
                else
                {
                    NewAdmin.Gender = "Female";
                }
                NewAdmin.Birth_Date = BirthDate_Time.Value;
                NewAdmin.Country    = Country_TextBox.Text;


                AdminController Control = new AdminController();

                bool IsAdded = Control.AddNewAdmin(NewAdmin);

                if (IsAdded)
                {
                    MessageBox.Show(Control.Message, "Information", MessageBoxButtons.OK);
                    this.Close();
                }
                else
                {
                    if (MessageBox.Show(Control.Message, "Error", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
                    {
                        this.Close();
                    }
                }
            }
        }