public ActionResult Create(FormCollection collection) { var content = new Content(); try { var contentcontent = new ContentContent(); this.RadynTryUpdateModel(content, collection); this.RadynTryUpdateModel(contentcontent, collection); if (ContentManagerComponent.Instance.ContentFacade.Insert(content, contentcontent)) { ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Succeed); return(RedirectToAction("Index")); } ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error); return(RedirectToAction("Index")); } catch (Exception exception) { ShowExceptionMessage(exception); TempData["Containers"] = new SelectList(ContentManagerComponent.Instance.ContainerFacade.SelectKeyValuePair(x => x.Id, x => x.Title, x => x.IsExternal == false), "Key", "Value"); return(View(content)); } }
public ActionResult Modify(string state, int contentId) { switch (state) { case "Modify": { var newcontent = new ContentContent() { LanguageId = SessionParameters.Culture }; if (contentId != 0) { var content = ContentManagerComponent.Instance.ContentFacade.Get(contentId); if (content != null) { newcontent = content.GetContent(SessionParameters.Culture); } } ViewBag.Lanuages = new SelectList(CommonComponent.Instance.LanguageFacade.Where(x => x.Enabled), "Id", "DisplayName"); return(PartialView("Modify", newcontent)); } case "Details": { var content = ContentManagerComponent.Instance.ContentFacade.Get(contentId); return(PartialView("DetailInfo", content.GetContent(SessionParameters.Culture))); } } return(null); }
public ActionResult Create(FormCollection collection) { var content = new Content(); try { var contentcontent = new ContentContent(); this.RadynTryUpdateModel(content, collection); this.RadynTryUpdateModel(contentcontent, collection); if (WebDesignComponent.Instance.ContentFacade.Insert(this.WebSite.Id, content, contentcontent)) { ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Succeed); return(RedirectToAction("Index")); } ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error); return(RedirectToAction("Index")); } catch (Exception exception) { ShowMessage(Resources.Common.ErrorInInsert + exception.Message, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error); TempData["Containers"] = new SelectList( WebDesignComponent.Instance.ContainerFacade.GetByWebSiteId(this.WebSite.Id), "Id", "Title"); return(View(content)); } }
public bool Insert(Content content, ContentContent contentContent) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); if (!new ContentBO().Insert(this.ConnectionHandler, content)) { throw new Exception("خطایی در ذخیره محتوا وجود دارد"); } if (contentContent != null) { contentContent.Id = content.Id; if (!new ContentContentBO().Insert(this.ConnectionHandler, contentContent)) { throw new Exception("خطایی در ذخیره محتوا وجود دارد"); } } this.ConnectionHandler.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); 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 ActionResult Create(FormCollection collection) { var content = new Content(); try { var contentcontent = new ContentContent(); this.RadynTryUpdateModel(content, collection); this.RadynTryUpdateModel(contentcontent, collection); if (CongressComponent.Instance.BaseInfoComponents.CongressContentFacade.Insert(this.Homa.Id, content, contentcontent)) { ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Succeed); return(this.SubmitRedirect(collection, new { Id = content.Id })); } ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error); return(Redirect("~/Congress/CongressContent/Index")); } catch (Exception exception) { ShowExceptionMessage(exception); FillTempData(); return(View(content)); } }
public static ContentContent GetContent(this Content content, string culture) { var firstOrDefault = new ContentContentFacade().Get(content.Id, culture); if (firstOrDefault != null) { return(firstOrDefault); } firstOrDefault = new ContentContent { Id = content.Id, Abstract = content.Abstract, Description = content.Description, Text = content.Text, Subject = content.Subject, Title = content.Title, }; return(firstOrDefault); }
public ActionResult ChangeCulture(int contentId, string langid) { if (string.IsNullOrEmpty(langid)) { return(null); } var contenet = new ContentContent() { LanguageId = langid }; if (contentId != 0) { var contentContent = ContentManagerComponent.Instance.ContentContentFacade.Get(contentId, langid); if (contentContent != null) { contenet = contentContent; } } ViewBag.Lanuages = new SelectList(CommonComponent.Instance.LanguageFacade.Where(x => x.Enabled), "Id", "DisplayName"); return(PartialView("Modify", contenet)); }
public bool Insert(Guid congressId, Content content, ContentContent contentContent) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); content.IsExternal = true; if ( !ContentManagerComponent.Instance.ContentTransactionalFacade(this.ContentManagerConnection) .Insert(content, contentContent)) { throw new Exception("خطایی در ذخیره محتوا وجود دارد"); } var congressContent = new CongressContent { ContentId = content.Id, CongressId = congressId }; if (!new CongressContentBO().Insert(this.ConnectionHandler, congressContent)) { throw new Exception(Resources.Congress.ErrorInSaveCongressContent); } 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 string GetHtml(Content content, ContentContent contentContent, bool hascontainer = true, Container DefaultContrainer = null) { if (content == null) { return(string.Empty); } var st = new StringBuilder(); if (!string.IsNullOrEmpty(content.UserScript)) { st.Append("<script type=\"text/javascript\">" + content.UserScript + "</script>"); } var contentContainer = content.Container; if (DefaultContrainer != null) { contentContainer = DefaultContrainer; } if (contentContainer == null || !hascontainer) { st.Append(contentContent.Text); } else { if (contentContainer.Html == null) { st.Append(contentContent.Text); } else { var htmltext = contentContainer.Html; var html = htmltext.Replace("{Body}", contentContent.Text); st.Append(html.Replace("{title}", contentContent.Title)); } } return(contentContent.Text.Length < 10 ? null : st.ToString()); }
public bool Insert(Guid websiteId, ContentManager.DataStructure.Content content, ContentContent contentcontent) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); content.IsExternal = true; if (!ContentManagerComponent.Instance.ContentTransactionalFacade(this.ContentManagerConnection).Insert(content, contentcontent)) { throw new Exception("خطایی در ذخیره محتوا وجود دارد"); } var congressContent = new Content { ContentId = content.Id, WebId = websiteId }; if (!new ContentBO().Insert(this.ConnectionHandler, congressContent)) { throw new Exception("خطایی در ذخیره محتوا وجود دارد"); } this.ConnectionHandler.CommitTransaction(); this.ContentManagerConnection.CommitTransaction(); return(true); } catch (KnownException knownException) { this.ConnectionHandler.RollBack(); this.ContentManagerConnection.RollBack(); throw new KnownException(knownException.Message, knownException); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.ContentManagerConnection.RollBack(); throw new KnownException(ex.Message, ex); } }