public ActionResult Create(FormCollection collection) { var news = new Radyn.News.DataStructure.News(); try { var newsproperty = new NewsProperty(); var newsContent = new NewsContent(); RadynTryUpdateModel(news, collection); RadynTryUpdateModel(newsproperty, collection); RadynTryUpdateModel(newsContent, collection); news.SaveDate = DateTime.Now; var file = Session["NewsImage"]; Session.Remove("NewsImage"); if (SessionParameters.User != null) { news.CreatorId = SessionParameters.User.Id; } if (WebDesignComponent.Instance.NewsFacade.Insert(this.WebSite.Id, news, newsContent, newsproperty, (HttpPostedFileBase)file)) { 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); return(View(news)); } }
public bool Insert(DataStructure.News news, NewsContent content, NewsProperty property, HttpPostedFileBase fileBase) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); if (fileBase != null) { news.ThumbnailId = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection) .Insert(fileBase); } if (!new NewsBO().Insert(this.ConnectionHandler, news)) { throw new Exception("خطایی در ذخیره اخبار وجود دارد"); } if (content != null) { content.Id = news.Id; if (!new NewsContentBO().Insert(this.ConnectionHandler, content)) { throw new Exception("خطایی در ذخیره محتوای اخبار وجود دارد"); } } if (property != null) { property.Id = news.Id; if (!new NewsPropertyBO().Insert(this.ConnectionHandler, property)) { throw new Exception("خطایی در ذخیره تنظیمات اخبار وجود دارد"); } } 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 ActionResult Modify(string state, int newsid = 0) { var newsContentTypes = NewsComponent.Instance.NewsContentTypeFacade.GetAll().ToList(); ViewBag.NewsContentType = new SelectList(newsContentTypes, "Id", "Title"); switch (state) { case "Modify": { var property = new NewsProperty(); if (newsid == 0) { return(PartialView("Modify", property)); } property = NewsComponent.Instance.NewsPropertyFacade.Get(newsid); if (property != null) { ViewBag.Files = NewsComponent.Instance.AttachedFileFacade.Where(file => file.NewsId == (int)newsid) .Select(file => file.File); } return(PartialView("Modify", property)); } case "Details": { var newsProperty = NewsComponent.Instance.NewsPropertyFacade.Get(newsid); if (newsProperty != null) { return(PartialView("DetailInfo", newsProperty)); } } break; } return(null); }
public bool Insert(Guid websiteId, News.DataStructure.News news, NewsContent newsContent, NewsProperty newsproperty, HttpPostedFileBase file) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.NewsConnection.StartTransaction(IsolationLevel.ReadUncommitted); news.IsExternal = true; if (!NewsComponent.Instance.NewsTransactionalFacade(this.NewsConnection).Insert(news, newsContent, newsproperty, file)) { throw new Exception("خطایی درذخیره اخبار وجود دارد"); } var congressNews = new Radyn.WebDesign.DataStructure.News { NewsId = news.Id, WebId = websiteId }; if (!new NewsBO().Insert(this.ConnectionHandler, congressNews)) { throw new Exception("خطایی درذخیره اخبار وجود دارد"); } this.ConnectionHandler.CommitTransaction(); this.NewsConnection.CommitTransaction(); return(true); } catch (KnownException knownException) { this.ConnectionHandler.RollBack(); this.NewsConnection.RollBack(); throw new KnownException(knownException.Message, knownException); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.NewsConnection.RollBack(); throw new KnownException(ex.Message, ex); } }
public bool Update(Guid congressId, News.DataStructure.News news, NewsContent newsContent, NewsProperty property, HttpPostedFileBase @base) { try { this.NewsConnection.StartTransaction(IsolationLevel.ReadUncommitted); news.IsExternal = true; if ( !NewsComponent.Instance.NewsTransactionalFacade(this.NewsConnection) .Update(news, newsContent, property, @base)) { throw new Exception("خطایی در ذخیره اخبار وجود دارد"); } this.NewsConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.NewsConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.NewsConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
set => SetValue(NewsProperty, value);
public bool Update(DataStructure.News obj, NewsContent content, NewsProperty property, HttpPostedFileBase fileBase) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); if (fileBase != null) { if (obj.ThumbnailId.HasValue && property.HasAttachment) { FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection) .Update(fileBase, obj.ThumbnailId.Value); } else { obj.ThumbnailId = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection) .Insert(fileBase); } } if (property != null) { if (!new NewsPropertyBO().Update(this.ConnectionHandler, property)) { throw new Exception("خطایی در ویرایش تنظیمات خبر وجود دارد"); } } if (content != null) { if (content.Id == 0) { content.Id = obj.Id; if (!new NewsContentBO().Insert(this.ConnectionHandler, content)) { throw new Exception("خطایی در ذخیره محتوای اخبار وجود دارد"); } } else { if (!new NewsContentBO().Update(this.ConnectionHandler, content)) { throw new Exception("خطایی در ویرایش محتوای اخبار وجود دارد"); } } } if (!new NewsBO().Update(this.ConnectionHandler, obj)) { throw new Exception("خطایی در ویرایش اخبار وجود دارد"); } 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); } }