protected void btnAdd_OnClick(object sender, EventArgs e) { if (txtCustomerID.Text.Trim().Length == 5) { Customer newCustomer = new Customer(txtCompanyName.Text); newCustomer.SetAssignedIdTo(txtCustomerID.Text); newCustomer.ContactName = txtContactName.Text; IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); if (!IsDuplicateOfExisting(newCustomer, customerDao)) { customerDao.Save(newCustomer); Response.Redirect("ListCustomers.aspx?action=added"); } else { lblMessage.Text = "<span style=\"color:red\">The ID you provided is already in use.</span><br />Please change the ID and try again."; } } else { lblMessage.Text = "<span style=\"color:red\">The ID you provide must be exactly 5 characters long.</span><br />Please change the ID and try again."; } }
public void TestGetById() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); Customer foundCustomer = customerDao.GetById(TestGlobals.TestCustomer.ID, false); Assert.AreEqual(TestGlobals.TestCustomer.CompanyName, foundCustomer.CompanyName); }
public void CanGetByExample() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); Customer exampleCustomer = new Customer(TestGlobals.TestCustomer.CompanyName); Customer foundCustomer = customerDao.GetUniqueByExample(exampleCustomer); Assert.AreEqual(TestGlobals.TestCustomer.CompanyName, foundCustomer.CompanyName); }
private void DisplayAllCustomers() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); grdEmployees.DataSource = customerDao.GetAll(); grdEmployees.DataBind(); }
private void DisplayAllCustomers() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); grdEmployees.DataSource = customerDao.GetAll(); grdEmployees.DataBind(); }
public void TestGetById() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); Customer foundCustomer = customerDao.GetById(TestGlobals.TestCustomer.ID, false); Assert.AreEqual(TestGlobals.TestCustomer.CompanyName, foundCustomer.CompanyName); }
public void CanGetByExample() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); Customer exampleCustomer = new Customer(TestGlobals.TestCustomer.CompanyName); Customer foundCustomer = customerDao.GetUniqueByExample(exampleCustomer); Assert.AreEqual(TestGlobals.TestCustomer.CompanyName, foundCustomer.CompanyName); }
private void UpdateCustomer() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); // Now that we're about to update the customer, be sure to lock the entity Customer customerToUpdate = customerDao.GetById(hidCustomerID.Value, true); // Changes to the customer object will be automatically committed at the end of the HTTP request customerToUpdate.CompanyName = txtCompanyName.Text; customerToUpdate.ContactName = txtContactName.Text; }
private void DisplayCustomerToEdit() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); // No need to lock the customer since we're just viewing the data Customer customerToEdit = customerDao.GetById(Request.QueryString["customerID"], false); ShowCustomerDetails(customerToEdit); ShowPastOrders(customerToEdit); ShowProductsOrdered(customerToEdit); }
private void UpdateCustomer() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); // Now that we're about to update the customer, be sure to lock the entity Customer customerToUpdate = customerDao.GetById(hidCustomerID.Value, true); // Changes to the customer object will be automatically committed at the end of the HTTP request customerToUpdate.CompanyName = txtCompanyName.Text; customerToUpdate.ContactName = txtContactName.Text; }
private void DisplayCustomerToEdit() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); // No need to lock the customer since we're just viewing the data Customer customerToEdit = customerDao.GetById(Request.QueryString["customerID"], false); ShowCustomerDetails(customerToEdit); ShowPastOrders(customerToEdit); ShowProductsOrdered(customerToEdit); }
public void TestGetOrdersShippedTo() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); Customer customer = customerDao.GetById(TestGlobals.TestCustomer.ID, false); // Give the customer its DAO dependency via a public setter customer.OrderDao = daoFactory.GetOrderDao(); IList<Order> ordersMatchingDate = customer.GetOrdersOrderedOn(new DateTime(1998, 3, 10)); Assert.AreEqual(1, ordersMatchingDate.Count); Assert.AreEqual(10937, ordersMatchingDate[0].ID); }
public void CanGetOrdersShippedTo() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); IOrderDao orderDao = daoFactory.GetOrderDao(); Customer customer = customerDao.GetById(TestGlobals.TestCustomer.ID, false); // Give the customer its DAO dependency via a public setter IList <Order> ordersMatchingDate = orderDao.GetOrdersOrderedOn(customer, new DateTime(1998, 3, 10)); Assert.AreEqual(1, ordersMatchingDate.Count); Assert.AreEqual(10937, ordersMatchingDate[0].ID); }
protected void btnAdd_OnClick(object sender, EventArgs e) { if (txtCustomerID.Text.Trim().Length == 5) { Customer newCustomer = new Customer(txtCompanyName.Text); newCustomer.SetAssignedIdTo(txtCustomerID.Text); newCustomer.ContactName = txtContactName.Text; IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); if (!IsDuplicateOfExisting(newCustomer, customerDao)) { customerDao.Save(newCustomer); Response.Redirect("ListCustomers.aspx?action=added"); } else { lblMessage.Text = "<span style=\"color:red\">The ID you provided is already in use.</span><br />Please change the ID and try again."; } } else { lblMessage.Text = "<span style=\"color:red\">The ID you provide must be exactly 5 characters long.</span><br />Please change the ID and try again."; } }