Beispiel #1
0
        public void CreateCustomerTest()
        {
            Customer newCustomer = CreateTestCustomer("Test", "LastName");

            cRepo.CreateCustomer(newCustomer);
            Assert.AreEqual(1, cRepo.GetAllCustomers().Count);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CustomerRepo customerrepo = new CustomerRepo();

            lbMessage.Text = "";
            if (customerrepo.DoesUsernameExist(txtUserName.Text))
            {
                lbMessage.Text      = "Username already exists!";
                lbMessage.ForeColor = System.Drawing.Color.Red;
                txtUserName.Text    = "";
                return;
            }
            if (customerrepo.DoesEmailExist(txtEmail.Text))
            {
                lbMessage.Text      = "Email already exists!";
                lbMessage.ForeColor = System.Drawing.Color.Red;
                txtEmail.Text       = "";
                return;
            }
            Model.Customer customer = new Model.Customer();
            customer.FirstName   = txtFirstName.Text;
            customer.LastName    = txtLastName.Text;
            customer.Username    = txtUserName.Text;
            customer.Password    = Security.Encrypt(ConfigurationManager.AppSettings["KeyCustomer"], txtPassword.Text);
            customer.Key         = ConfigurationManager.AppSettings["KeyCustomer"];
            customer.Email       = txtEmail.Text;
            customer.Phone       = txtPhone.Text;
            customer.DateOfBirth = ToSQL.SQLToDateTimeNull(txtDateOfBirth.Text);
            customer.Gender      = rdbtnGender.SelectedIndex == 0 ? true : false;
            customer.DateCreated = DateTime.Now;
            int i = customerrepo.CreateCustomer(customer);

            Response.Redirect("Management-Customer.aspx");
        }
 public ActionResult Create(Customer customer)
 {
     if (ModelState.IsValid)
     {
         int id = customerRepo.CreateCustomer(customer);
         return(RedirectToAction("Customers", "Home"));
     }
     return(View(customer));
 }
        private async Task Create()
        {
            await CustomerRepo.CreateCustomer(_customer);

            ToastService.ShowSuccess($"Action successful." +
                                     $"Customer \"{_customer.Name}\" successfully added.");
            _customer = new Customer();
            _editContext.OnValidationStateChanged += ValidationChanged;
            _editContext.NotifyValidationStateChanged();
        }
        private void AddNewCustomer()
        {
            Console.Clear();
            Console.WriteLine("Please enter the customer's first name:");
            string fname = Console.ReadLine();

            Console.Clear();
            Console.WriteLine("Please enter the customer's last name");
            string lname = Console.ReadLine();

            Console.Clear();
            CustomerType type = SelectCustomerType();

            Customer newCustomer = new Customer(fname, lname, type);

            cRepo.CreateCustomer(newCustomer);

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Customer added!");
            Console.ForegroundColor = ConsoleColor.White;

            PrintCustomerData(newCustomer);
        }
 public bool CreateCustomer(string name, string adress, string zip, string town, string telephone)
 {
     return(customerRepo.CreateCustomer(name, adress, zip, town, telephone));
 }
Beispiel #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Bank SQL database app 1.0");
            string message   = "";
            string userInput = null;

            do
            {
                userInput = ChooseAction();
                switch (userInput.ToUpper())
                {
                case "1":
                    Console.WriteLine("Choose action:");
                    Console.WriteLine("1 = Create a bank");
                    Console.WriteLine("2 = Print bank information");
                    Console.WriteLine("3 = Update bank.");
                    Console.WriteLine("4 = Delete bank.");
                    string BankChoice = Console.ReadLine();

                    if (BankChoice.ToUpper() == "1")
                    {
                        bankRepository.CreateBank();
                        Console.WriteLine("Bank created.");
                    }
                    else if (BankChoice.ToUpper() == "2")
                    {
                        PrintBank();
                    }

                    else if (BankChoice.ToUpper() == "3")
                    {
                        bankRepository.UpdateBank();
                        Console.WriteLine("Bank updated.");
                    }
                    else if (BankChoice.ToUpper() == "4")
                    {
                        bankRepository.DeleteBank(1);
                        Console.WriteLine("Bank has been deleted.");
                    }
                    else
                    {
                        Console.WriteLine("Given option does not exist.");
                    }

                    break;

                case "2":
                    Console.WriteLine("Choose action:");
                    Console.WriteLine("1 = Create a new customer");
                    Console.WriteLine("2 = Print  customer's  info");
                    Console.WriteLine("3 = Print all customers");
                    Console.WriteLine("4 = Update customer's info");
                    Console.WriteLine("5 = Delete customer");
                    string CustomerOption = Console.ReadLine();

                    if (CustomerOption.ToUpper() == "1")
                    {
                        customerRepository.CreateCustomer();
                        Console.WriteLine("Customer created.");
                    }
                    else if (CustomerOption.ToUpper() == "2")
                    {
                        PrintCustomer();
                    }
                    else if (CustomerOption.ToUpper() == "3")
                    {
                        PrintAllCustomers();
                    }
                    else if (CustomerOption.ToUpper() == "4")
                    {
                        customerRepository.UpdateCustomer();
                        Console.WriteLine("Customer updated.");
                    }
                    else if (CustomerOption.ToUpper() == "5")
                    {
                        customerRepository.DeleteCustomer(1);
                    }
                    break;

                case "3":
                    Console.WriteLine("Choose action:");
                    Console.WriteLine("1 = Create a new account");
                    Console.WriteLine("2 = Print account's info");
                    Console.WriteLine("3 = Print all accounts in a bank");
                    Console.WriteLine("4 = Print all accounts of a customer");
                    Console.WriteLine("5 = Delete account by IBAN");
                    string AccountOption = Console.ReadLine();

                    if (AccountOption.ToUpper() == "1")
                    {
                        accountRepository.CreateNewAccount();
                        Console.WriteLine("New accoumt created.");
                    }
                    else if (AccountOption.ToUpper() == "2")
                    {
                        PrintAccount("FI4250001510000023");
                    }
                    else if (AccountOption.ToUpper() == "3")
                    {
                        PrintAccounts();
                    }
                    else if (AccountOption.ToUpper() == "4")
                    {
                        PrintAll(1);
                    }
                    else if (AccountOption.ToUpper() == "5")
                    {
                        accountRepository.DeleteAccount("FI4250001510000023");
                        Console.WriteLine("Account has been deleted.");
                    }
                    break;

                case "4":
                    Console.WriteLine("Choose action:");
                    Console.WriteLine("1 = Create a transaction");
                    Console.WriteLine("2 = Print customer's transactions");
                    string TransactionOption = Console.ReadLine();

                    if (TransactionOption.ToUpper() == "1")
                    {
                        var         amount = accountRepository.AddTransaction();
                        Transaction trns   = new Transaction {
                            Iban = "FI4250001510000023", Amount = amount
                        };
                        accountRepository.CreateTransaction(trns);
                        accountRepository.UpdateAccountBalance(amount);
                        Console.WriteLine($"Transaction of {amount} has been recorded.");
                    }
                    else if (TransactionOption.ToUpper() == "2")
                    {
                        PrintTransaction("FI4250001510000023");
                    }
                    break;

                default:
                    message = "Invalid option.";
                    break;
                }
                Console.WriteLine(message);
                Console.ReadKey();
                Console.Clear();
            }while (true);
        }
Beispiel #8
0
 public bool CreateCustomer(string name, string address, string city, string zip, string phone, string email, string comment)
 {
     return(customerRepo.CreateCustomer(name, address, city, zip, phone, email, comment));
 }