示例#1
0
        public void AddCustomer_UserIsAdded_ReturnsTrue()
        {
            //Arrange
            bool       expected   = true;
            CustomerDL customerDL = new CustomerDL();
            //Act
            bool actual = customerDL.AddCustomer("TestCase User", DateTime.Now, 1);

            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public void AddCustomer_UserTryingToAddInUnKnownBranch_ReturnsFalse()
        {
            //Arrange
            bool       expected   = false;
            CustomerDL customerDL = new CustomerDL();
            //Act
            bool actual = customerDL.AddCustomer("TestCase User", DateTime.Now, 7);

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public IHttpActionResult PostCustomer(Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = db.AddCustomer(customer);


            return(CreatedAtRoute("DefaultApi", new { id = customer.CID }, customer));
        }
示例#4
0
        public AjaxResult Post([FromBody] Customer customerItem)
        {
            var _ajaxResult = new AjaxResult();

            try
            {
                _CustomerDL.AddCustomer(customerItem);
            }
            catch (Exception ex)
            {
                _ajaxResult.Data    = ex;
                _ajaxResult.Success = false;
                _ajaxResult.Message = Resources.errorVN;
            }
            return(_ajaxResult);
        }
        public AjaxResult SaveCustomer([FromBody] Customer _customer)
        {
            var _ajaxResult = new AjaxResult();

            try
            {
                _cusDL.AddCustomer(_customer);
            }
            catch (Exception ex)
            {
                _ajaxResult.Success = false;
                _ajaxResult.Message = "Lỗi Lưu data";
                _ajaxResult.Data    = ex;
            }
            return(_ajaxResult);
        }
示例#6
0
        /// <summary>
        /// Hàm thực hiện chức năng thêm khách hàng
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public AjaxResult AddCustomerData(Customer customer)
        {
            AjaxResult ajaxResult = new AjaxResult();

            try
            {
                CustomerDL.AddCustomer(customer);
                ajaxResult.Message            = Resources.successVN;
                ajaxResult.Data.totalCustomer = CustomerDL.GetNumberOfCustomer();
            }
            catch (Exception ex)
            {
                ajaxResult.Message = Resources.errorVN;
                ajaxResult.Success = false;
                ajaxResult.Data    = ex;
            }
            return(ajaxResult);
        }
示例#7
0
 private void submitButton_Click(object sender, EventArgs e)
 {
     customerNameTextBox.Text = customerNameTextBox.Text.Trim();
     if (customerNameTextBox.Text == "" || customerNameTextBox.Text.Any(ch => !(Char.IsLetter(ch) || char.IsWhiteSpace(ch))))
     {
         MessageBox.Show("Invalid Arguments!!!");
     }
     else if (customerDL.AddCustomer(customerNameTextBox.Text, dateOpenedPicker.Value, branchComboBox.SelectedIndex + 1))
     {
         MessageBox.Show("SUCCESSFULLY ADDED!!!");
         this.Close();
     }
     else
     {
         MessageBox.Show("DataBase Connection Issue");
         this.Close();
     }
 }
示例#8
0
 public static void AddCustomer(Customer customer)
 {
     CustomerDL.AddCustomer(customer);
 }