public void TestDelete()
        {
            testCustomerRepo.AddCustomer("John", "Doe", Customer.CustomerType.Current);
            testCustomerRepo.AddCustomer("XX", "XX", Customer.CustomerType.Current);

            Assert.IsTrue(testCustomerRepo.DeleteCustomer("John", "Doe"));
        }
        // DELETE: api/Customer/5
        public HttpResponseMessage Delete(string Id)
        {
            var objectId = new ObjectId(Id);

            _repo.DeleteCustomer(objectId);
            return(Request.CreateResponse(HttpStatusCode.Moved));
        }
Exemple #3
0
        public void DeleteCustomerTest()
        {
            Customer testCust = CreateTestCustomer("Julius", "Caesar");

            cRepo.CreateCustomer(testCust);
            Assert.IsTrue(cRepo.DeleteCustomer(testCust.LastName));
        }
        private void DeleteCustomer()
        {
            Console.WriteLine("Please enter the last name of the customer you wish to delete:");
            string lname = Console.ReadLine();
            // TODO: Extract this method ?
            Customer customerToDelete = cRepo.GetCustomerByLName(lname);

            if (customerToDelete == null)
            {
                Console.Clear();
                Console.WriteLine("Sorry, I could not find that customer.");
                return;
            }

            bool success = cRepo.DeleteCustomer(customerToDelete.LastName);

            if (!success)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Something went wrong. Customer {customerToDelete.LastName} could not be deleted.");
                return;
            }
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Customer successfully deleted!");
        }
Exemple #5
0
        private void btnDeleteCustomer_Click(object sender, EventArgs e)
        {
            var selectedCustomer = (Customer)dgCustomers.SelectedRows[0].DataBoundItem;

            AppointmentRepo.DeleteAppointmentsForCustomer(selectedCustomer.Id);
            CustomerRepo.DeleteCustomer(selectedCustomer.Id);
            AddressRepo.DeleteAddress(selectedCustomer.AddressId);
            BindGrids();
        }
        private async Task DeleteCustomer(int id)
        {
            await CustomerRepo.DeleteCustomer(id);

            //Paging needs to be recalculated after a delete.
            if (_requestParams.PageNumber > 1 && CustomerList.Count == 1)
            {
                _requestParams.PageNumber--;
            }

            await GetCustomers();
        }
Exemple #7
0
 public HttpResponseMessage DeleteCustomer([FromBody] CUSTOMERIDSOBJECT customerIdsObj)
 {
     try
     {
         _CustomerRepo.DeleteCustomer(customerIdsObj.IDs);
         return(Request.CreateResponse(HttpStatusCode.OK, "Customer(s) deleted successfully"));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, $"An error has occured. Error details: {ex.Message}"));
     }
 }
        private void DeleteCustomer()
        {
            Console.WriteLine("Enter the first name of the customer you would like to delete:");
            string first = Console.ReadLine();

            Console.WriteLine("Enter the last name of the customer you would like to delete:");
            string last = Console.ReadLine();

            if (customerList.DeleteCustomer(first, last))
            {
                Console.WriteLine("Customer record deleted.");
            }
            else
            {
                Console.WriteLine("Customer not found. No deletion occured.");
            }
        }
        private void Button2_Click(object sender, EventArgs e)
        {
            if (IsEmpty(customerIdBox.Text.Trim()))
            {
                MessageBox.Show("Hey bro, Select customer first!");
            }
            else
            {
                string customerId = customerIdBox.Text.Trim();

                var deleted = _customerRepo.DeleteCustomer(customerId);
                if (deleted > 0)
                {
                    Clear();
                    MessageBox.Show("Successfully deleted...!!");
                    CustomerTableFetch();
                }
            }
        }
        public async Task <IActionResult> DeleteCustomer(int id)
        {
            try
            {
                var customer = _repo.FindById(id);
                if (customer.Result == null)
                {
                    _logger.LogError($"Customer with id: {id}, hasn't been found in db.");
                    return(NotFound($"Customer with Id {id} not found."));
                }
                await _repo.DeleteCustomer(id);

                _logger.LogInformation($"Customer with id: {id}, Deleted successfully.");
                return(StatusCode(200, "Customer Deleted successfully."));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside Add Customer action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
Exemple #11
0
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            Customer cm = new Customer();

            cm.Name        = this.CustomerNameTb.Text;
            cm.PhoneNumber = this.PhoneTB.Text;
            cm.From        = tablefrom;
            cm.To          = tableto;
            cm.BusId       = tablebusid;
            cm.Date        = tabledate;
            cm.Time        = tabletime;
            cm.Type        = tabletype;
            cm.SeatNumber  = tableseatnumber;
            cm.Fare        = Convert.ToInt32(tablefare);
            string [] seatnumbers = tableseatnumber.Split(',');


            if (cr.DeleteCustomer(cm))
            {
                MessageBox.Show("Deleted");
                this.ShowAllBtn_Click(sender, e);
                int     i  = 0;
                Bus     b  = new Bus();
                BusRepo br = new BusRepo();
                while (seatnumbers[i] != "")
                {
                    b = br.GetBus(tablebusid, tabledate, tabletime);
                    br.updatefordelete(b, seatnumbers[i]);
                    i++;
                }
                MessageBox.Show(b.NumberOfSeats + " " + seatnumbers.Length);
                b.NumberOfSeats = (b.NumberOfSeats + seatnumbers.Length - 1);
                br.UpdateNumberSeat(b);
            }

            else
            {
                MessageBox.Show("Can Not Delete");
            }
        }
Exemple #12
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgv_CustomerList.SelectedRows.Count > 0)
                {
                    switch (MessageBox.Show("Delete selected record(s)?", "Superior Investment", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                    {
                    case DialogResult.Yes:
                        List <long> IDs = new List <long>();
                        for (int i = 0; i < dgv_CustomerList.SelectedRows.Count; i++)
                        {
                            IDs.Add(long.Parse(dgv_CustomerList.SelectedRows[i].Cells[0].Value.ToString()));
                        }
                        if (_CustomerRepo.DeleteCustomer(IDs))
                        {
                            MessageBox.Show("Customer(s) deleted successfully!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            if (!bgwGetRecords.IsBusy)
                            {
                                bgwGetRecords.RunWorkerAsync();
                            }
                        }
                        break;

                    case DialogResult.No:
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Please select atleast one customer to delete!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{Utilities.ERRORMESSAGE} \n Error details: {ex.Message}", "Superior Investment!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void DeleteBtnn_Click_1(object sender, EventArgs e)
        {
            Login l = new Login();

            l.Id = this.CustIdTF.Text;
            Customer cust = new Customer();

            cust.CustId = this.CustIdTF.Text;

            if (lr.DeleteUser(l))
            {
                if (cr.DeleteCustomer(cust))
                {
                    MessageBox.Show("Deleted");
                    this.RefreshBtnn_Click_1(sender, e);
                    this.ViewAllBtnn_Click_1(sender, e);
                }
            }
            else
            {
                MessageBox.Show("Can Not Delete");
            }
        }
        public ActionResult Delete(Customer customer)
        {
            int result = customerRepo.DeleteCustomer(customer.Id.ToString());

            return(RedirectToAction("Customers", "Home"));
        }
Exemple #15
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string val = this.dgvCustomer.CurrentRow.Cells["customer_id"].Value.ToString();

            cmrRepo.DeleteCustomer(cu, val);
        }
Exemple #16
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);
        }
Exemple #17
0
 public void DeleteCustomer(int id)
 {
     repo.DeleteCustomer(id);
 }