Exemple #1
0
        public bool Insert(IConnectionHandler connectionHandler,
                           IConnectionHandler enterpriseNodeConnectionconnectionHandler,
                           IConnectionHandler statisticConnectionconnectionHandler, Homa homa,
                           HttpPostedFileBase file, List <HomaAlias> homaAliases)
        {
            if (
                !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(
                    enterpriseNodeConnectionconnectionHandler)
                .Insert(homa.Owner, file))
            {
                throw new Exception("خطایی در ذخیره اطلاعات شخصی صاحب همایش وجود دارد");
            }
            homa.OwnerId = homa.Owner.Id;
            if (!this.Insert(connectionHandler, homa))
            {
                throw new Exception(Resources.Congress.ErrorInSaveCongress);
            }
            var homaAliasBo = new HomaAliasBO();

            foreach (var homaAliase in homaAliases)
            {
                homaAliase.CongressId = homa.Id;
                homaAliase.Homa       = homa;
                if (!homaAliasBo.Insert(connectionHandler, homaAliase))
                {
                    throw new Exception(Resources.Congress.ErrorInSaveCongress);
                }
            }

            if (
                !StatisticComponents.Instance.WebSiteTransactionalFacade(statisticConnectionconnectionHandler)
                .Modify(
                    StringUtils.Decrypt(homa.InstallPath) +
                    (string.IsNullOrEmpty(homa.VirtualDirectory) ? "" : homa.VirtualDirectory),
                    homa.CongressTitle, homa.OwnerId))
            {
                throw new Exception(Resources.Congress.ErrorInSaveCongress);
            }
            return(true);
        }
Exemple #2
0
        public bool Update(IConnectionHandler connectionHandler,
                           IConnectionHandler enterpriseNodeConnectionconnectionHandler,
                           IConnectionHandler statisticConnectionconnectionHandler, Homa homa,

                           HttpPostedFileBase file, List <HomaAlias> homaAliases)
        {
            if (
                !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(
                    enterpriseNodeConnectionconnectionHandler)
                .Update(homa.Owner, file))
            {
                return(false);
            }



            if (!new HomaBO().Update(connectionHandler, homa))
            {
                throw new Exception(Resources.Congress.ErrorInEditCongress);
            }
            var homaAliasBo = new HomaAliasBO();
            var list        = homaAliasBo.Where(connectionHandler, x => x.CongressId == homa.Id);

            foreach (var homaAliase in homaAliases)
            {
                var homaAlias = homaAliasBo.Get(connectionHandler, homaAliase.Id);
                if (homaAlias == null)
                {
                    homaAliase.CongressId = homa.Id;
                    homaAliase.Homa       = homa;
                    if (!homaAliasBo.Insert(connectionHandler, homaAliase))
                    {
                        throw new Exception(Resources.Congress.ErrorInSaveCongress);
                    }
                }
                else
                {
                    homaAliase.Homa = homa;
                    if (!homaAliasBo.Update(connectionHandler, homaAliase))
                    {
                        throw new Exception(Resources.Congress.ErrorInSaveCongress);
                    }
                }
            }
            foreach (var homaAliase in list)
            {
                if (homaAliases.Any(x => x.Id == homaAliase.Id))
                {
                    continue;
                }
                if (!homaAliasBo.Delete(connectionHandler, homaAliase.Id))
                {
                    throw new Exception(Resources.Congress.ErrorInSaveCongress);
                }
            }

            if (!StatisticComponents.Instance.WebSiteTransactionalFacade(statisticConnectionconnectionHandler)
                .Modify(StringUtils.Decrypt(homa.InstallPath), homa.CongressTitle, homa.OwnerId))
            {
                throw new Exception(Resources.Congress.ErrorInEditCongress);
            }
            return(true);
        }