public bool DeletePartialWithUrl(string url) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); var partialsBO = new PartialsBO(); var @where = partialsBO.Where(ConnectionHandler, partials => partials.Url == url.ToLower()); if ([email protected]()) { return(true); } foreach (var partialse in where) { if (!partialsBO.Delete(this.ConnectionHandler, partialse.Id)) { throw new Exception("خطایی در حذف صفحه وجود دارد"); } } this.ConnectionHandler.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public List <PartialLoad> GetHtmlPartials(Guid htmlId, string culture, Container DefaultContrainer = null) { try { var list = new PartialLoadBO().Where(this.ConnectionHandler, load => load.HtmlDesginId == htmlId); var partialModels = new List <PartialLoad>(); var contentBo = new ContentBO(); var contentContentBo = new ContentContentBO(); var partialsBo = new PartialsBO(); var contenetidlist = list.Where(partialLoad => partialLoad.PartialId.ToInt() > 0).Select(x => x.PartialId.ToInt()); var partialidlist = list.Where(partialLoad => partialLoad.PartialId.ToGuid() != Guid.Empty).Select(x => x.PartialId.ToGuid()); var contents = new List <Content>(); var ContentContents = new List <ContentContent>(); var partialses = new List <Partials>(); if (contenetidlist.Any()) { contents = contentBo.Where(ConnectionHandler, x => x.Id.In(contenetidlist)); ContentContents = contentContentBo.Where(ConnectionHandler, x => x.Id.In(contenetidlist) && x.LanguageId == culture); } if (partialidlist.Any()) { partialses = partialsBo.Where(ConnectionHandler, x => x.Id.In(partialidlist)); } foreach (var partialLoad in list) { var partialModel = new PartialLoad(); if (partialLoad.PartialId.ToInt() > 0) { int Id = partialLoad.PartialId.ToInt(); var content = contents.FirstOrDefault(x => x.Id == Id); if (content == null) { continue; } var contentContent = ContentContents.FirstOrDefault(x => x.Id == Id) ?? new ContentContent { Id = content.Id, Abstract = content.Abstract, Description = content.Description, Text = content.Text, Subject = content.Subject, Title = content.Title, }; partialModel.Content = content; partialModel.PartialId = partialLoad.PartialId; partialModel.Type = Enums.PartialTypes.ContentManager; partialModel.Html = contentBo.GetHtml(content, contentContent, partialLoad.HasContainer, DefaultContrainer); } else { var Id = partialLoad.PartialId.ToGuid(); var partials = partialses.FirstOrDefault(x => x.Id == Id); if (partials == null) { continue; } partialModel.Partials = partials; partialModel.PartialId = partialLoad.PartialId; partialModel.Type = Enums.PartialTypes.Modual; } partialModel.CustomId = partialLoad.CustomId; partialModel.position = partialLoad.position; partialModel.HasContainer = partialLoad.HasContainer; partialModels.Add(partialModel); } return(partialModels); } catch (KnownException ex) { 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); } }