public ActionResult CustomerConfirmation(string Email) { var customer = facade.GetCustomerGateway().ReadByEmail(Email); if (customer == null) { customer = new Customer() { Email = Email }; } return View(customer); }
public ActionResult CustomerPlaceOrder(Customer customer) { if (facade.GetCustomerGateway().ReadById(customer.Id) == null) { facade.GetCustomerGateway().Add(customer); } facade.GetOrderGateway().Add(new Order() { Customer = customer, Movies = ((List<Movie>)Session["Cart"]), Date = DateTime.Now }); Session["Cart"] = null; return RedirectToAction("Index", "Home"); }
public void CreatePermitErrorTest() { Customer customer = new Customer(); customer.customer_name = "bltestcreatecustomer"; customer.customer_pw = "fakepassword1"; // TODO: Initialize to an appropriate value customer.customer_type = "undertest"; 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 List<string> errors = new List<string>(); using (var scop = new System.Transactions.TransactionScope()) { 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); 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); Record record1 = new Record(); record1.customer_id = customer.customer_id; record1.permit_type_id = permit.id; record1.expire_date = DateTime.Parse("11/11/2011"); record1.valid = true; BLRecords.CreatePermit(record1, ref errors); Assert.AreEqual(1, errors.Count); } }
/// <summary> /// Tests the customer. /// </summary> /// <param name="customer">The customer.</param> public void TestCustomer(Customer customer) { Assert.IsNotNull(customer); var customerRef = CreateCustomer(); Assert.AreEqual(customer.CustomerId, customerRef.CustomerId); Assert.AreEqual(customer.Address, customerRef.Address); Assert.AreEqual(customer.City, customerRef.City); Assert.AreEqual(customer.Country, customerRef.Country); Assert.AreEqual(customer.ContactName, customerRef.ContactName); Assert.AreEqual(customer.CompanyName, customerRef.CompanyName); Assert.AreEqual(customer.Phone, customerRef.Phone); Assert.AreEqual(customer.PostalCode, customerRef.PostalCode); Assert.AreEqual(customer.Fax, customerRef.Fax); Assert.AreEqual(customer.Region, customerRef.Region); }
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 void InsertCustomerErrorTest() { List<string> errors = new List<string>(); BLCustomers.CreateCustomer(null, ref errors); Assert.AreEqual(1, errors.Count); errors = new List<string>(); Customer customer = new Customer(); customer.customer_name = ""; customer.customer_pw = "fake123"; BLCustomers.CreateCustomer(customer, ref errors); Assert.AreEqual(1, errors.Count); }
public void UpdateCustomer(Customer customer, ref List<string> errors) { BLCustomers.UpdateCustomer(customer, ref errors); }