public ActionResult Invoice(Invoice invoice)
        {
            Reservation reservation = (Reservation)Session["newReservation"];
            reservation.InvoiceCity = invoice.City;
            reservation.InvoiceNumber = invoice.Number;
            reservation.InvoiceStreet = invoice.Street;
            reservation.InvoiceZipCode = invoice.ZipCode;
            reservation.BankAccountNumber = invoice.BankAccountNumber;

            // alles klaar, verzenden maar
            reservationRepository.Create(reservation);
            return RedirectToAction("Success");
        }
        public void CreateInvoiceTest()
        {
            List<string> errors = new List<string>();
            BLInvoices.CreateInvoice(null, ref errors);
            Assert.AreEqual(1, errors.Count);

            errors = new List<string>();

            Invoice invoice = new Invoice();
            invoice.invoice_type = "";
            invoice.customer_id = -2;
            invoice.item_id = 3;
            invoice.amt_paid = 100;
            invoice.pay_method = "debit card";
            BLInvoices.CreateInvoice(invoice, ref errors);
            Assert.AreEqual(3, errors.Count);
        }
        public void UpdateInvoiceTableTest()
        {
            List<string> errors = new List<string>();
            BLInvoices.UpdateInvoiceTable(null, ref errors);
            Assert.AreEqual(1, errors.Count);

            errors = new List<string>();

            Invoice invoice = new Invoice();
            invoice.invoice_id = 2;
            invoice.amt_paid = 0;
            invoice.pay_method = "debit card";
            invoice.pay_date = DateTime.Today;
            BLInvoices.UpdateInvoiceTable(invoice, ref errors);
            Assert.AreEqual(0, errors.Count);
        }
        public void CreateCustomerTest()
        {
            Customer customer = new Customer();
            List<string> errors = new List<string>();
            customer.customer_name = "bltestcreatecustomer";
            customer.customer_pw = "fakepassword1"; // TODO: Initialize to an appropriate value
            customer.customer_type = "undergrad";
            customer.first_name = "test"; // TODO: Initialize to an appropriate value
            customer.middle_name = "test"; // TODO: Initialize to an appropriate value
            customer.last_name = "test"; // TODO: Initialize to an appropriate value
            Customer check = new Customer();
            using (var scop = new System.Transactions.TransactionScope())
            {
                //insert
                BLCustomers.CreateCustomer(customer, ref errors);
                //check = BLCustomers.GetCustomerInfo(customer.customer_id.ToString(), ref errors);
                check = BLCustomers.CheckCustomerLoginPassword(customer.customer_name, customer.customer_pw, ref errors);
                Assert.AreEqual(0, errors.Count);
                Assert.IsNotNull(check);
                Assert.AreEqual(customer.customer_id, check.customer_id);
                Assert.AreEqual(customer.customer_name, check.customer_name);
                Assert.AreEqual(customer.customer_pw, check.customer_pw);
                Assert.AreEqual(customer.customer_type, check.customer_type);
                Assert.AreEqual(customer.first_name, check.first_name);
                Assert.AreEqual(customer.middle_name, check.middle_name);
                Assert.AreEqual(customer.last_name, check.last_name);

                //update test
                customer.customer_pw = "fakepassword1"; // TODO: Initialize to an appropriate value
                customer.first_name = "updated BL "; // TODO: Initialize to an appropriate value
                customer.middle_name = "updated BL"; // TODO: Initialize to an appropriate value
                customer.last_name = "updated BL"; // TODO: Initialize to an appropriate value
                BLCustomers.UpdateCustomer(customer, ref errors);
                check = BLCustomers.GetCustomerInfo(customer.customer_id.ToString(), ref errors);
                Assert.AreEqual(0, errors.Count);
                Assert.IsNotNull(check);
                Assert.AreEqual(customer.customer_id, check.customer_id);
                Assert.AreEqual(customer.customer_name, check.customer_name);
                Assert.AreEqual(customer.customer_pw, check.customer_pw);
                Assert.AreEqual(customer.customer_type, check.customer_type);
                Assert.AreEqual(customer.first_name, check.first_name);
                Assert.AreEqual(customer.middle_name, check.middle_name);
                Assert.AreEqual(customer.last_name, check.last_name);

                //delete test
                BLCustomers.DeleteCustomer(customer.customer_id.ToString(), ref errors);
                check = BLCustomers.GetCustomerInfo(customer.customer_id.ToString(), ref errors);
                Assert.AreEqual(0, errors.Count);
                Assert.IsNull(check);

                //get record, invoice and violation test
                BLCustomers.CreateCustomer(customer, ref errors);

                Permit permit = new Permit();
                permit.permit_name = "bl customertest";
                permit.customer_type = "undergrad";
                permit.price = 50;
                permit.v_description = "test";
                BLPermitTypes.CreatePermitType(permit, ref errors);

                Record record = new Record();
                record.customer_id = customer.customer_id;
                record.permit_type_id = permit.id;
                record.expire_date = DateTime.Parse("11/11/2011");
                record.valid = true;
                BLRecords.CreatePermit(record, ref errors);

                Invoice invoice1 = new Invoice();
                invoice1.invoice_type = "purchase";
                invoice1.customer_id = customer.customer_id;
                invoice1.item_id = record.permit_id;
                invoice1.amt_paid = 200;
                invoice1.pay_method = "debit";
                invoice1.pay_date = DateTime.Parse("11/11/2011");
                BLInvoices.CreateInvoice(invoice1, ref errors);

                Violation violation = new Violation();
                violation.permit_id = record.permit_id;
                violation.fee = 48;
                violation.v_description = "testing create violations - test1";
                violation.violation_date = DateTime.Parse("11/11/2011");
                violation.paid = false;
                BLViolations.CreateViolation(violation, ref errors);

                Invoice invoice2 = new Invoice();
                invoice2.invoice_type = "violation";
                invoice2.customer_id = customer.customer_id;
                //invoice2.item_id = violation.violation_id;
                invoice2.item_id = 500;
                invoice2.amt_paid = 220;
                invoice2.pay_method = "debit";
                invoice2.pay_date = DateTime.Parse("11/11/2011");
                BLInvoices.CreateInvoice(invoice2, ref errors);

                List<Violation> expected_violations = new List<Violation>();
                expected_violations.Add(violation);
                List<Violation> violations = BLViolations.GetCustomerViolations(record.customer_id.ToString(), ref errors);
                for (int index = 0; index < expected_violations.Count; index++)
                {
                    Assert.AreEqual(violations[index].permit_id, expected_violations[index].permit_id);
                    Assert.AreEqual(violations[index].fee, expected_violations[index].fee);
                    Assert.AreEqual(violations[index].v_description, expected_violations[index].v_description);
                    Assert.AreEqual(violations[index].violation_date, expected_violations[index].violation_date);
                    Assert.AreEqual(violations[index].paid, expected_violations[index].paid);
                }
                List<Invoice> expected_invoices = new List<Invoice>();
                expected_invoices.Add(invoice1);
                expected_invoices.Add(invoice2);
                List<Invoice> invoices = new List<Invoice>();
                invoices = BLCustomers.GetCustomerInvoiceHistory(customer.customer_id.ToString(), ref errors);

                Assert.AreEqual(0, errors.Count);
                for (int index = 0; index < expected_invoices.Count; index++)
                {
                    Assert.AreEqual(expected_invoices[index].invoice_id, invoices[index].invoice_id);
                    Assert.AreEqual(expected_invoices[index].invoice_type, invoices[index].invoice_type);
                    Assert.AreEqual(expected_invoices[index].customer_id, invoices[index].customer_id);
                    Assert.AreEqual(expected_invoices[index].item_id, invoices[index].item_id);
                    Assert.AreEqual(expected_invoices[index].amt_paid, invoices[index].amt_paid);
                    Assert.AreEqual(expected_invoices[index].pay_method, invoices[index].pay_method);
                    Assert.AreEqual(expected_invoices[index].pay_date, invoices[index].pay_date);
                }

                //update record and invoice test
                record.valid = false;
                BLRecords.UpdateRecordTable(record, ref errors);
                violation.fee = 250;
                violation.paid = true;
                BLViolations.UpdateAmountViolation(violation, ref errors);
                BLViolations.UpdatePayViolation(violation.violation_id.ToString(), ref errors);

                expected_violations = new List<Violation>();
                expected_violations.Add(violation);
                violations = BLViolations.GetCustomerViolations(record.customer_id.ToString(), ref errors);
                for (int index = 0; index < expected_violations.Count; index++)
                {
                    Assert.AreEqual(violations[index].permit_id, expected_violations[index].permit_id);
                    Assert.AreEqual(violations[index].fee, expected_violations[index].fee);
                    Assert.AreEqual(violations[index].v_description, expected_violations[index].v_description);
                    Assert.AreEqual(violations[index].violation_date, expected_violations[index].violation_date);
                    Assert.AreEqual(violations[index].paid, expected_violations[index].paid);
                }

                //update invoice test
                invoice2.amt_paid = 110;
                invoice2.pay_method = "credit";
                invoice2.pay_date = DateTime.Parse("12/11/2011");
                BLInvoices.UpdateInvoiceTable(invoice2, ref errors);

                expected_invoices = new List<Invoice>();
                expected_invoices.Add(invoice1);
                expected_invoices.Add(invoice2);
                invoices = new List<Invoice>();
                invoices = BLCustomers.GetCustomerInvoiceHistory(customer.customer_id.ToString(), ref errors);

                Assert.AreEqual(0, errors.Count);
                for (int index = 0; index < expected_invoices.Count; index++)
                {
                    Assert.AreEqual(expected_invoices[index].invoice_id, invoices[index].invoice_id);
                    Assert.AreEqual(expected_invoices[index].invoice_type, invoices[index].invoice_type);
                    Assert.AreEqual(expected_invoices[index].customer_id, invoices[index].customer_id);
                    Assert.AreEqual(expected_invoices[index].item_id, invoices[index].item_id);
                    Assert.AreEqual(expected_invoices[index].amt_paid, invoices[index].amt_paid);
                    Assert.AreEqual(expected_invoices[index].pay_method, invoices[index].pay_method);
                    Assert.AreEqual(expected_invoices[index].pay_date, invoices[index].pay_date);
                }

                //getpermit based on customer level test
                System.Diagnostics.Debug.WriteLine(customer.customer_id);
                Permit check_permit = BLPermitTypes.GetPermitsBasedOnCustomer(record.customer_id.ToString(), ref errors);
                Assert.AreEqual(0, errors.Count);
                Assert.AreEqual(permit.id, check_permit.id);
                Assert.AreEqual(permit.permit_name, check_permit.permit_name);
                Assert.AreEqual(permit.customer_type, check_permit.customer_type);
                Assert.AreEqual(permit.price, check_permit.price);
                Assert.AreEqual(permit.v_description, check_permit.v_description);

                //getpermit list
                List<Permit> permits = BLPermitTypes.GetPermitsList(ref errors);
                Assert.AreEqual(1, permits.Count);

            }
        }
 public ActionResult Invoice()
 {
     Invoice v = new Invoice();
     return View(v);
 }