public District AssignSecondaryToDistrict(int districtId, int personId)
        {
            var faulted = new District();

            try
            {
                DBSalesperson personDb = new DBSalesperson();
                var           person   = personDb.Get(personId);
                var           district = db.Get(districtId);
                db.AssignSecondary(person, district);
                return(new District()
                {
                    IsFaulted = false
                });
            }
            catch (DataLayerArgumentException e)
            {
                faulted.IsFaulted = true;
                faulted.DataLayerArgumentException = e.Message;
            }
            catch (DataLayerException e)
            {
                faulted.IsFaulted          = true;
                faulted.DataLayerException = e.Message;
            }
            return(faulted);
        }
Пример #2
0
        public void DBDistrictTest_AssignSecondary_fail_DistrictID()
        {
            DBDistrict db     = new DBDistrict();
            var        person = new Salesperson()
            {
                Id = 1
            };
            var district = new District()
            {
                Id = -1
            };

            db.AssignSecondary(person, district);
        }
Пример #3
0
        public void DBDistrictTest_AssignSecondary_DeleteSecondary()
        {
            DBDistrict db     = new DBDistrict();
            var        person = new Salesperson()
            {
                Id = 3
            };
            var district = new District()
            {
                Id = 1
            };
            var countOld = db.Get(1).SecondarySalespeople.Count();

            db.AssignSecondary(person, district);

            var countNew = db.Get(1).SecondarySalespeople.Count();

            Assert.AreNotEqual(countOld, countNew);

            db.DeleteSecondary(person, district);

            countNew = db.Get(1).SecondarySalespeople.Count();
            Assert.AreEqual(countOld, countNew);
        }