Changeset 76

User picture

Author: marisic.net

(2009/01/27 22:02) About 3 years ago


  

Affected files

Updated UnityWeb/UnityWeb/Base/BusinessConversation.cs Download diff

7576
2
2
3
using System;
3
using System;
4
using System.Web;
4
using System.Web;
5
using Microsoft.Practices.Unity;
6
using PostSharp.Laos;
5
using PostSharp.Laos;
7
using Repository.NHibernateDataAccess.Conversation;
6
using Repository.NHibernateDataAccess.Conversation;
8
7

Updated UnityWeb/UnityWeb/Domain/Business/Employee.cs Download diff

7576
19
        public string Phone { get; set; }
19
        public string Phone { get; set; }
20
        public string Salutation { get; set; }
20
        public string Salutation { get; set; }
21
        public string JobTitle { get; set; }
21
        public string JobTitle { get; set; }
22
        public DateTime? HireDate { get; set; }
22
    }
23
    }
23
}
24
}

Updated UnityWeb/UnityWeb/Repository/NHibernateDataAccess/Conversation/Conversation.cs Download diff

7576
26
        /// </summary>
26
        /// </summary>
27
        public void Start()
27
        public void Start()
28
        {
28
        {
29
            if (Session != null)
29
            if (Session != null && (Session.IsOpen || Session.IsConnected))
30
            {
30
            {
31
                Abort();
31
                Abort();
32
            }
32
            }
...
...
40
        public void Pause()
40
        public void Pause()
41
        {
41
        {
42
            Commit(Session);
42
            Commit(Session);
43
            
44
        }
43
        }
45
44
46
        /// <summary>
45
        /// <summary>
...
...
51
            if (Session == null)
50
            if (Session == null)
52
                Start();
51
                Start();
53
52
54
            if (Session == null) 
53
            if (Session == null)
55
                throw new AccessViolationException("Session could not be created");
54
                throw new AccessViolationException("Session could not be created");
56
55
57
            if (!Session.IsConnected)
56
            if (!Session.IsConnected)

Updated UnityWeb/UnityWeb/Repository/NHibernateDataAccess/Providers/EmployeeDataProvider.cs Download diff

7576
42
            return _conversation.Session.CreateCriteria(typeof(Territory)).List<Territory>();
42
            return _conversation.Session.CreateCriteria(typeof(Territory)).List<Territory>();
43
        }
43
        }
44
44
45
        void IEmployeeDataProvider.Save(Employee employee)
46
        {
47
            _conversation.Session.SaveOrUpdate(employee);
48
        }
49
45
        #endregion
50
        #endregion
46
    }
51
    }
47
}
52
}

Updated UnityWeb/UnityWeb/Repository/NHibernateDataAccess/Providers/Interfaces/IEmployeeDataProvider.cs Download diff

7576
13
        Employee GetEmployee(int id);
13
        Employee GetEmployee(int id);
14
        void AddEmployee(Employee employee);
14
        void AddEmployee(Employee employee);
15
        IList<Territory> GetTerritories();
15
        IList<Territory> GetTerritories();
16
        void Save(Employee employee);
16
    }
17
    }
17
}
18
}

Updated UnityWeb/UnityWeb/Repository/Test/RepositoryTest/EmployeeConversationTest.cs Download diff

7576
52
        [Test]
52
        [Test]
53
        public void AddEmployee()
53
        public void AddEmployee()
54
        {
54
        {
55
            var employee = new Employee
56
                               {
57
                                   //   Address = new Address {City = "Harrisburg", CountryRegionName = "USA", PostalCode = "17104", StateProvinceName = "PA", AddressLine1 = "123 Fake st"},
58
                                   // BirthDate = new DateTime(1984, 6, 26),
59
                                   FirstName = "Chris",
60
                                   LastName = "Marisic",
61
                                   //HireDate = DateTime.Now,
62
                                   JobTitle = ".NET Master",
63
                                   //Phone = "717-123-4568",
64
                                   Salutation = "Mr."
65
                               };
66
            _provider.AddEmployee(employee);
67
55
68
            Assert.IsTrue(employee.Id > 0);
69
        }
56
        }
70
57
71
        [Test]
58
        [Test]
...
...
76
63
77
        [Test]
64
        [Test]
78
        [BusinessConversation]
65
        [BusinessConversation]
79
        public void GetEmployees()
66
        public void BusinessConversationTest()
80
        {
67
        {
81
            const int id = 9;
68
            const int id = 9;
82
            var employee = _provider.GetEmployee(id);
69
            var employee = _provider.GetEmployee(id);
70
            employee.LastName = employee.FirstName + employee.LastName;
71
            _provider.Save(employee);
83
72
84
            Assert.IsNotNull(employee);
73
            Assert.IsNotNull(employee);
85
            //Assert.IsTrue(employee.Id.HasValue);
74
            //Assert.IsTrue(employee.Id.HasValue);
...
...
94
83
95
            Assert.IsTrue(territories.Count > 0);
84
            Assert.IsTrue(territories.Count > 0);
96
            Assert.IsFalse(string.IsNullOrEmpty(territories[0].Id));
85
            Assert.IsFalse(string.IsNullOrEmpty(territories[0].Id));
86
87
            var employee2= new Employee
88
            {
89
                //   Address = new Address {City = "Harrisburg", CountryRegionName = "USA", PostalCode = "17104",
StateProvinceName = "PA", AddressLine1 = "123 Fake st"},
90
                // BirthDate = new DateTime(1984, 6, 26),
91
                FirstName = "Chris",
92
                LastName = "Marisic",
93
                HireDate = DateTime.Now,
94
                JobTitle = ".NET Master",
95
                //Phone = "717-123-4568",
96
                Salutation = "Mr."
97
            };
98
            _provider.AddEmployee(employee2);
99
100
            Assert.IsTrue(employee.Id > 0);
97
        }
101
        }
98
102
99
        [Test]
103
        [Test]