Beispiel #1
0
        public void CustomerDaoTests()
        {
            Assert.AreEqual(91, customerDao.GetAll().Count);

            Customer c = new Customer(new DefaultCustomerClassificationCalculator());

            c.Id          = "MPOLL";
            c.CompanyName = "Interface21";
            customerDao.Save(c);
            c = customerDao.Get("MPOLL");
            Assert.AreEqual(c.Id, "MPOLL");
            Assert.AreEqual(c.CompanyName, "Interface21");

            //Without flushing, nothing changes in the database:
            int customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers");

            Assert.AreEqual(91, customerCount);

            //Flush the session to execute sql in the db.
            SessionFactoryUtils.GetSession(sessionFactory, true).Flush();

            //Now changes are visible outside the session but within the same database transaction
            customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers");
            Assert.AreEqual(92, customerCount);

            Assert.AreEqual(92, customerDao.GetAll().Count);

            c.CompanyName = "SpringSource";

            customerDao.Update(c);

            c = customerDao.Get("MPOLL");
            Assert.AreEqual(c.Id, "MPOLL");
            Assert.AreEqual(c.CompanyName, "SpringSource");

            customerDao.Delete(c);


            SessionFactoryUtils.GetSession(sessionFactory, true).Flush();
            customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers");
            Assert.AreEqual(92, customerCount);

            try
            {
                c = customerDao.Get("MPOLL");
                Assert.Fail("Should have thrown HibernateObjectRetrievalFailureException when finding customer with Id = MPOLL");
            }
            catch (HibernateObjectRetrievalFailureException e)
            {
                Assert.AreEqual("Customer", e.PersistentClassName);
            }
        }
    public void ProcessCustomer()
    {
        string customerId = "ERNSH";

        // check, if exists
        Customer customer = customerDao.Get(customerId);

        //Find all orders for customer and ship them
        this.fulfillmentService.ProcessCustomer(customer.Id);
        //assertions....

        // prepare for display - note that OrderDetails are loaded lazy here!
        foreach (Order order in customer.Orders)
        {
            Debug.Assert(order.OrderDetails.Count > 0);
            foreach (OrderDetail details in order.OrderDetails)
            {
                details.Quantity = details.Quantity - 1;
                // do something here
            }
        }
    }
Beispiel #3
0
 public CustomerDto Get(int id)
 {
     return(DtoConverter.Convert(customerDao.Get(id)));
 }
Beispiel #4
0
 //Validates Sign in info
 public static IBankCustomer SignIn(string userName, string password)
 {
     return(customerDao.Get(userName, password));
 }
Beispiel #5
0
 public IDataResult <Customer> GetById(int id)
 {
     return(new SuccessDataResult <Customer>(_customerDao.Get(ı => ı.CustomerId == id)));
 }
 public Customer GetById(int id)
 {
     return(_customerDao.Get(customer => customer.CustomerId == id));
 }