public List <KeyValuePair <SupportType, bool> > GetSupportTypeModel(Guid congressId) { try { var list = new SupportTypeBO().Where(this.ConnectionHandler, x => x.CongressId == congressId); var getSupportTypeModel = new List <KeyValuePair <SupportType, bool> >(); var configurationSupportTypeBo = new ConfigurationSupportTypeBO(); var @select = configurationSupportTypeBo.Select(ConnectionHandler, x => x.SupportTypeId, x => x.CongressId == congressId); foreach (var supportType in list) { bool added = @select.Any(x => x.Equals(supportType.Id)); getSupportTypeModel.Add(new KeyValuePair <SupportType, bool>(supportType, added)); } return(getSupportTypeModel); } 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); } }
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); } }
public bool ModifySupportTypes(IConnectionHandler connectionHandler, IConnectionHandler contentManagerConnection, Guid congressId, SupportType supportType) { var configurationSupportTypeBo = new ConfigurationSupportTypeBO(); var byFilter = configurationSupportTypeBo.Get(connectionHandler, congressId, supportType.Id); if (byFilter == null) { var configurationSupportType = new ConfigurationSupportType { SupportTypeId = supportType.Id, CongressId = congressId }; if (!configurationSupportTypeBo.Insert(connectionHandler, configurationSupportType)) { throw new Exception(Resources.Congress.ErrorInSaveSupporterPartialInConfiguration); } } var partialsTransactionalFacade = ContentManagerComponent.Instance.PartialsTransactionalFacade(contentManagerConnection); var pl = new Partials { Enabled = true, Title = supportType.Title, Url = supportType.PartialUrl(), ContextName = "همایشات", Id = Guid.NewGuid(), OperationId = Radyn.Common.Constants.OperationId.CongressOperationId, RefId = congressId.ToString(), CurrentUICultureName = supportType.CurrentUICultureName }; var firstOrDefault = partialsTransactionalFacade.FirstOrDefault(x => x.Url.ToLower() == pl.Url.ToLower()); if (firstOrDefault != null) { pl.Id = firstOrDefault.Id; if (!partialsTransactionalFacade.Update(pl)) { throw new Exception(Resources.Congress.ErrorInSaveSupporterPartialInConfiguration); } return(true); } if (!partialsTransactionalFacade.Insert(pl)) { throw new Exception(Resources.Congress.ErrorInSaveSupporterPartialInConfiguration); } return(true); }