public IActionResult Create(CreatePersonViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    UploadFile upload         = new UploadFile(_hosting);
                    string     uniqueFileName = upload.UploadedFile(model.image, @"wwwroot\images\People");


                    _repositoryCustomer.AddNew(new Customer()
                    {
                        Adresse     = model.Adresse,
                        CreatedBy   = User.Identity.Name,
                        DateOfBirth = model.DateOfBirth,
                        First_Name  = model.First_Name,
                        Last_Name   = model.Last_Name,
                        genre       = model.genre,
                        image       = uniqueFileName,
                        Phone       = model.Phone
                    });

                    return(RedirectToAction(nameof(Index)).WithSuccess("Ajouter", "vous avez ajouté avec succès "));
                }

                return(View().WithDanger("Ajouter", "Echeq d'ajout !!!"));
            }
            catch (AjouterException e)
            {
                ModelState.AddModelError("", e.Message);
                return(View());
            }
        }
예제 #2
0
        private void btnAddCustomer_Click(object sender, EventArgs e)
        {
            CustomerService cusService = new CustomerService();

            try
            {
                Customer obj = new Customer()
                    {
                        ID = Convert.ToInt32(txtID.Text),
                        FirstName = txtFirstName.Text,
                        LastName = txtLastName.Text,
                        Address = txtAddress.Text,
                        City = txtCity.Text,
                        State = txtState.Text,
                        Country = txtCountry.Text,
                        Email = txtEmail.Text,
                        Phone = txtPhone.Text,
                        mobile = txtMobile.Text
                    };

                cusService.AddNew(obj);
                ClearNewCustomerFields();
                MessageBox.Show(this, "Customer Added.", "Succeed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Customer Insert Fail : " + ex.Message);
            }
        }
예제 #3
0
        private void btnAddCustomer_Click(object sender, EventArgs e)
        {
            CustomerService cusService = new CustomerService();

            try
            {
                Customer obj = new Customer()
                {
                    ID        = Convert.ToInt32(txtID.Text),
                    FirstName = txtFirstName.Text,
                    LastName  = txtLastName.Text,
                    Address   = txtAddress.Text,
                    City      = txtCity.Text,
                    State     = txtState.Text,
                    Country   = txtCountry.Text,
                    Email     = txtEmail.Text,
                    Phone     = txtPhone.Text,
                    mobile    = txtMobile.Text
                };

                cusService.AddNew(obj);
                ClearNewCustomerFields();
                MessageBox.Show(this, "Customer Added.", "Succeed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Customer Insert Fail : " + ex.Message);
            }
        }
예제 #4
0
 public int AddNew(Customer customer)
 {
     if (this.CheckExists(customer.WaitingNumber))
     {
         return(0);
     }
     else
     {
         return(customerService.AddNew(customer));
     }
 }
        public void TestAddNew()
        {
            var id = _db.Count() + 1;

            var customer = TestDataHelper.NewCustomer();

            customer.CustomerId = id;

            // Act
            _db.AddNew(customer);

            // Assert
            var result = _db.GetById(id);

            Assert.IsNotNull(result);
            Assert.AreEqual(customer.LastName, result.LastName);
        }