Beispiel #1
0
        public bool Delete(IConnectionHandler connectionHandler,
                           IConnectionHandler enterpriseNodeConnectionconnectionHandler,
                           IConnectionHandler statisticConnectionconnectionHandler, params object[] keys)
        {
            var obj         = new HomaBO().Get(connectionHandler, keys);
            var homaAliasBo = new HomaAliasBO();
            var list        = homaAliasBo.Where(connectionHandler, x => x.CongressId == obj.Id);

            foreach (var homaAliase in list)
            {
                if (!homaAliasBo.Delete(connectionHandler, homaAliase.Id))
                {
                    throw new Exception(Resources.Congress.ErrorInSaveCongress);
                }
            }
            if (!new HomaBO().Delete(connectionHandler, keys))
            {
                throw new Exception(Resources.Congress.ErrorInDeleteCongress);
            }
            var webSiteTransactionalFacade =
                StatisticComponents.Instance.WebSiteTransactionalFacade(statisticConnectionconnectionHandler);


            var byFilter = webSiteTransactionalFacade.Where(x => x.OwnerId == obj.OwnerId);

            if (byFilter != null)
            {
                foreach (var webSite in byFilter)
                {
                    if (!webSiteTransactionalFacade.Delete(webSite.Id))
                    {
                        throw new Exception("خطایی در حذف آمار سایت وجود دارد");
                    }
                }
            }
            else
            {
                if (
                    !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(
                        enterpriseNodeConnectionconnectionHandler).Delete(obj.OwnerId))
                {
                    return(false);
                }
            }
            return(true);
        }