Example #1
0
        public void ThisActivityAlreadyExistInThisActivity()
        {
            _economicActivityManager = (EconomicActivityManager)container["EconomicActivityManager"];
            EconomicActivity activityParentA = new EconomicActivity
            {
                Name   = "Services",
                Parent = null
            };

            activityParentA.Id = _economicActivityManager.AddEconomicActivity(activityParentA);
            EconomicActivity activityParentB = new EconomicActivity
            {
                Name   = "Services",
                Parent = null
            };

            activityParentB.Id = _economicActivityManager.AddEconomicActivity(activityParentB);
            EconomicActivity activityA = new EconomicActivity
            {
                Name   = "ServicesA",
                Parent = activityParentA,
            };

            activityA.Id = _economicActivityManager.AddEconomicActivity(activityA);

            Assert.AreEqual(true, _economicActivityManager.ThisActivityAlreadyExist("ServicesA", activityParentA.Id));
        }
Example #2
0
        public int AddEconomicActivity(EconomicActivity pEconomicActivity)
        {
            if (pEconomicActivity.Name == String.Empty)
            {
                throw new OpenCbsDoaSaveException(OpenCbsDOASaveExceptionEnum.NameIsNull);
            }

            if (_doam.ThisActivityAlreadyExist(pEconomicActivity.Name, pEconomicActivity.Parent.Id))
            {
                throw new OpenCbsDoaSaveException(OpenCbsDOASaveExceptionEnum.AlreadyExist);
            }

            if (pEconomicActivity.Parent.Id == 0)
            {
                pEconomicActivity.Parent = null;
            }

            return(_doam.AddEconomicActivity(pEconomicActivity));
        }