Exemplo n.º 1
0
 public Daycare(DateTime date, Dog dog, Cost daycareCost, User user)
 {
     this.Date = date;
     this.Dog = dog;
     this.DaycareCost = daycareCost;
     this.User = user;
 }
Exemplo n.º 2
0
 public Boarding(DateTime date, bool isDaycare, Dog dog, Cost boardingCost, User user)
 {
     this.Date = date;
     this.IsDaycare = isDaycare;
     this.Dog = dog;
     this.BoardingCost = boardingCost;
     this.User = user;
 }
Exemplo n.º 3
0
 public Grooming(GroomingType groomingType, Double cost, DateTime date, Dog dog, User user)
 {
     this.GroomingType = groomingType;
     this.Cost = cost;
     this.Date = date;
     this.Dog = dog;
     this.User = user;
 }
Exemplo n.º 4
0
 public Training(DateTime date, CostType classType, Cost classCost, Dog dog, User user)
 {
     this.Date = date;
     this.ClassType = classType;
     this.ClassCost = classCost;
     this.Dog = dog;
     this.User = user;
 }
Exemplo n.º 5
0
 public void Update(Dog dog)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     using (ITransaction transaction = session.BeginTransaction())
     {
         session.Update(dog);
         transaction.Commit();
     }
 }
Exemplo n.º 6
0
        public void Can_add_new_dog()
        {
            var dog = new Dog { FirstName = "Adam", LastName = "Patel" };
            IDogRepository repository = new DogRepository();
            repository.Add(dog);

            // use session to try to load the dog
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Dog>(dog.DogId);
                // Test that the dog was successfully inserted
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(dog, fromDb);
                Assert.AreEqual(dog.FirstName, fromDb.FirstName);
                Assert.AreEqual(dog.LastName, fromDb.LastName);
            }

            repository.Remove(dog);
        }
Exemplo n.º 7
0
        public void Can_add_multiple_new_dogs()
        {
            ISession session = _sessionFactory.OpenSession();

            int countBefore = getDogTableSize(session);

            ITransaction tx = session.BeginTransaction();
            Dog dog1 = new Dog();
            dog1.FirstName = "Luis";
            dog1.LastName = "Patel";
            session.Save(dog1);

            Dog dog2 = new Dog();
            dog2.FirstName = "Clark";
            dog2.LastName = "Patel";
            session.Save(dog2);

            Dog dog3 = new Dog();
            dog3.FirstName = "Jason";
            dog3.LastName = "Patel";
            session.Save(dog3);

            tx.Commit();

            Assert.AreEqual(countBefore + 3, getDogTableSize(session));

            tx = session.BeginTransaction();

            session.Delete(dog1);
            session.Delete(dog2);
            session.Delete(dog3);

            tx.Commit();

            session.Close();
        }
Exemplo n.º 8
0
        private bool IsInCollection(Dog dog, ICollection<Dog> fromDb)
        {
            bool result = false;

            foreach (var item in fromDb)
            {
                if (dog.DogId == item.DogId)
                {
                    result = true;
                    break;
                }
            }
            return result;
        }
Exemplo n.º 9
0
 public PickupDropoff(DateTime date, Dog dog, User user)
 {
     this.Date = date;
     this.Dog = dog;
     this.User = user;
 }
Exemplo n.º 10
0
        private bool dataGridView1_RowValidating(int index, Dog dog)
        {
            if (dog.FirstName == null)
            {
                dataGridView1.Rows[index].ErrorText = "Dog's First Name must not be empty.";
                return false;
            }
            else if (dog.LastName == null)
            {
                dataGridView1.Rows[index].ErrorText = "Dog's Last Name must not be empty.";
                return false;
            }

            return true;
        }
Exemplo n.º 11
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.IsCurrentCellDirty)
            {
                if (dirtyDogsMap.Keys.Contains(e.RowIndex))
                {
                    dirtyDogsMap.Remove(e.RowIndex);
                }

                Dog dog = new Dog();

                string dogId = (string)dataGridView1.Rows[e.RowIndex].Cells["DogIdColumn"].Value;
                dog.DogId = dogId;

                string dogFirstName = (string)dataGridView1.Rows[e.RowIndex].Cells["DogFirstNameColumn"].Value;
                if (dogFirstName != null)
                {
                    dog.FirstName = dogFirstName;
                }

                string dogLastName = (string)dataGridView1.Rows[e.RowIndex].Cells["DogLastNameColumn"].Value;
                if (dogLastName != null)
                {
                    dog.LastName = dogLastName;
                }

                dirtyDogsMap.Add(e.RowIndex, dog);
            }
        }