public SaveResult UpdateCNVersion(NewsFlash model, string[] pictureUrls, int version) { if (CheckCNTitleExt(model)) { return(new SaveResult(false, "This news flash already exists!")); } if (CheckENTitleExt(model)) { return(new SaveResult(false, "This news flash already exists!")); } using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { new NewsFlashDAC().UpdateCNVersion(model); new NewsFlashDAC().DeleteFlashFilesByIdAndVer(model.Id, version); if (pictureUrls != null) { new NewsFlashDAC().CreateNewsFlashFiles(model.Id, pictureUrls, version); } scope.Complete(); } return(new SaveResult(true)); }
public NewsFlash CheckByENTitle(NewsFlash model) { string sql = @"select * from [dbo].[NewsFlash] where ENTitle=@ENTitle and Id!=@Id "; using (var con = ReadConnection()) { return(con.QueryFirstOrDefault <NewsFlash>(sql, new { ENTitle = model.ENTitle, Id = model.Id })); } }
public int CreateNewsFlash(NewsFlash model) { string sql = @"INSERT INTO [dbo].[NewsFlash] ([CNTitle] ,[ENTitle] ,[CNPageView] ,[CNContent] ,[ENContent] ,[CNSource] ,[ENSource], [Status] ,[CreateTime] ,[ModifyTime] ,[AccountsId] ,[ENPageView],[CNGood],[CNBad],[ENGood],[ENBad]) VALUES (@CNTitle ,@ENTitle,@CNPageView ,@CNContent ,@ENContent,@CNSource,@ENSource, @Status,@CreateTime,@ModifyTime,@AccountsId,@ENPageView ,@CNGood ,@CNBad ,@ENGood ,@ENBad );SELECT SCOPE_IDENTITY()"; using (var con = WriteConnection()) { return(con.ExecuteScalar <int>(sql, model)); } }
public ActionResult Edit(int Id) { NewsFlash nf = new NewsFlash(); nf.Id = -1; if (Id > 0) { nf = _component.GetById(Id); } ViewBag.CoverPictureList = _component.GetFlashFilesById(Id); return(View(nf)); }
public bool UpdateCNVersion(NewsFlash model) { string sql = @"UPDATE [dbo].[NewsFlash] SET [CNTitle] = @CNTitle,[CNContent] = @CNContent,[CNSource] =@CNSource, [Status] = @Status,[ModifyTime] = @ModifyTime ,[CNGood]=@CNGood ,[CNBad]=@CNBad,[ENGood]=@CNGood ,[ENBad]=@CNBad WHERE Id=@Id"; using (var con = WriteConnection()) { return(con.Execute(sql, new { CNTitle = model.CNTitle, CNContent = model.CNContent, CNSource = model.CNSource, Status = model.Status, Id = model.Id, ModifyTime = DateTime.UtcNow, CNGood = model.CNGood, //中英文版本 利空利好数同步 所以更新中文版时,英文版的数量也同步为中文版输入的数量 ,英文版反之 CNBad = model.CNBad, ENGood = model.CNGood, ENBad = model.CNBad }) > 0); } }
public bool UpdateENVersion(NewsFlash model) { string sql = @"UPDATE [dbo].[NewsFlash] SET [ENTitle] = @ENTitle,[ENContent] = @ENContent,[ENSource] =@ENSource, [Status] = @Status,[ModifyTime] = @ModifyTime ,[CNGood]=@ENGood ,[CNBad]=@ENBad,[ENGood]=@ENGood ,[ENBad]=@ENBad WHERE Id=@Id"; using (var con = WriteConnection()) { return(con.Execute(sql, new { ENTitle = model.ENTitle, ENContent = model.ENContent, ENSource = model.ENSource, Status = model.Status, Id = model.Id, ModifyTime = DateTime.UtcNow, ENGood = model.ENGood, ENBad = model.ENBad, CNGood = model.ENGood, CNBad = model.ENBad }) > 0); } }
public ActionResult SavePublishFlash(NewsFlashEditModel model) { SaveResult result = new SaveResult(); if (model.Id > 0)//编辑 { if (model.Version == (int)FlashVersion.CN) { result = _component.UpdateCNVersion(new NewsFlash { CNGood = model.CNGood, CNBad = model.CNBad, CNTitle = model.CNTitle, CNContent = model.CNContent, CNSource = model.CNSource, Status = (NewsFlashStatus)model.Status, Id = model.Id }, model.CNCoverPictureUrlList, model.Version); } if (model.Version == (int)FlashVersion.EN) { result = _component.UpdateENVersion(new NewsFlash { ENGood = model.ENGood, ENBad = model.ENBad, ENTitle = model.ENTitle, ENContent = model.ENContent, ENSource = model.ENSource, Status = (NewsFlashStatus)model.Status, Id = model.Id }, model.ENCoverPictureUrlList, model.Version); } } else //新增 { NewsFlash flash = new NewsFlash { CNTitle = model.CNTitle, ENTitle = model.ENTitle, CNContent = model.CNContent, ENContent = model.ENContent, CNSource = model.CNSource, ENSource = model.ENSource, Status = (NewsFlashStatus)model.Status, AccountsId = AccountInfo.Id, CNPageView = 0, ENPageView = 0, CreateTime = DateTime.UtcNow, ModifyTime = null, CNGood = (model.Version == (int)FlashVersion.CN ? model.CNGood : model.ENGood), CNBad = (model.Version == (int)FlashVersion.CN ? model.CNBad : model.ENBad), ENGood = (model.Version == (int)FlashVersion.EN ? model.ENGood : model.CNGood), ENBad = (model.Version == (int)FlashVersion.EN ? model.ENBad : model.CNBad) }; if (model.Version == (int)FlashVersion.CN) { result = new NewsFlashComponent().Create(flash, model.CNCoverPictureUrlList, model.Version); } else { result = new NewsFlashComponent().Create(flash, model.ENCoverPictureUrlList, model.Version); } } return(Json(result.toJson())); }
public ActionResult Add() { NewsFlash news = new NewsFlash(); return(View(news)); }
public bool CheckENTitleExt(NewsFlash model) { NewsFlash nf = new NewsFlashDAC().CheckByENTitle(model); return(nf != null); }