public override bool Delete(params object[] keys)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);

                var supportTypeBo = new SupportTypeBO();
                var obj           = supportTypeBo.Get(this.ConnectionHandler, keys);
                var url           = obj.PartialUrl();
                var list          = new SupporterBO().Any(ConnectionHandler,
                                                          supporter => supporter.SupportTypeId == obj.Id);
                if (list)
                {
                    throw new Exception(Resources.Congress.ErrorInDeleteSupportTypeBecuaseThereAreSupportWithThisType);
                }
                var configurationSupportTypes = new ConfigurationSupportTypeBO().Any(ConnectionHandler,
                                                                                     supporter => supporter.SupportTypeId == obj.Id);
                if (configurationSupportTypes)
                {
                    throw new Exception(Resources.Congress.ErrorInEditConfigurationBecauseThereErrorInDeleteSupportType);
                }
                if (
                    !ContentManager.ContentManagerComponent.Instance.PartialsTransactionalFacade(
                        this.ContentManagerConnection).DeletePartialWithUrl(url))
                {
                    return(false);
                }
                if (!supportTypeBo.Delete(this.ConnectionHandler, keys))
                {
                    throw new Exception(Resources.Congress.ErrorInDeleteSupportType);
                }
                this.ConnectionHandler.CommitTransaction();
                this.ContentManagerConnection.CommitTransaction();

                return(true);
            }

            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.ContentManagerConnection.RollBack();

                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.ContentManagerConnection.RollBack();

                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
示例#2
0
        public bool Update(Supporter supporter, HttpPostedFileBase file)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                if (file != null)
                {
                    var fileTransactionalFacade =
                        FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection);
                    var lanuageContent = new SupporterBO().GetLanuageContent(base.ConnectionHandler,
                                                                             supporter.CurrentUICultureName, supporter.Id);
                    if (!string.IsNullOrEmpty(lanuageContent.Image))
                    {
                        fileTransactionalFacade
                        .Update(file, lanuageContent.Image.ToGuid());
                    }
                    else
                    {
                        supporter.Image =
                            fileTransactionalFacade
                            .Insert(file, new File()
                        {
                            MaxSize = 200
                        }).ToString();
                    }
                }


                if (!new SupporterBO().Update(this.ConnectionHandler, supporter))
                {
                    throw new Exception(Resources.Congress.ErrorInEditSupporter);
                }
                this.ConnectionHandler.CommitTransaction();
                this.FileManagerConnection.CommitTransaction();
                return(true);
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
        public SupportType GetSupportWithSupporters(short id)
        {
            try
            {
                var supportType = new SupportTypeBO().Get(this.ConnectionHandler, id);
                if (supportType == null)
                {
                    return(null);
                }
                var list = new SupporterBO().OrderBy(this.ConnectionHandler, x => x.Sort, x => x.SupportTypeId == id);
                switch (supportType.ShowType)
                {
                case (byte)Enums.SupporterShowType.Image:
                    supportType.Supporters = list.Where(x => x.Image != null).ToList();
                    break;

                case (byte)Enums.SupporterShowType.ImageAndTitle:
                    supportType.Supporters = list;
                    break;

                case (byte)Enums.SupporterShowType.OnlyTitle:
                    supportType.Supporters = list.Where(x => !string.IsNullOrEmpty(x.Title)).ToList();
                    break;
                }
                return(supportType);
            }
            catch (KnownException ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }