/// <summary> /// 新增新聞 /// </summary> /// <param name="news">被新增的新聞</param> /// <returns>新增後的新聞</returns> public News CreateNews(News news) { return FTISDao.CreateNews(news); }
/// <summary> /// 更新新聞 /// </summary> /// <param name="news">被更新的新聞</param> /// <returns>更新後的新聞</returns> public News UpdateNews(News news) { return FTISDao.UpdateNews(news); }
/// <summary> /// 刪除新聞 /// </summary> /// <param name="news">被刪除的新聞</param> public void DeleteNews(News news) { FTISDao.DeleteNews(news); }
protected void LoadEntity(News entity) { if (entity != null) { #region 中文欄位 EntityId = entity.NewsId; Name = entity.Name; SortId = entity.SortId; Status = entity.Status; PostDate = entity.PostDate; Content = entity.Content; Pic1 = entity.Pic1; Pic1Name = entity.Pic1Name; Pic2 = entity.Pic2; Pic2Name = entity.Pic2Name; Pic3 = entity.Pic3; Pic3Name = entity.Pic3Name; AFile1 = entity.AFile1; AFile1Name = entity.AFile1Name; AFile2 = entity.AFile2; AFile2Name = entity.AFile2Name; AFile3 = entity.AFile3; AFile3Name = entity.AFile3Name; AUrl = entity.AUrl; AUrl1 = entity.AUrl1; AUrl1Link = entity.AUrl1Link; AUrl2 = entity.AUrl2; AUrl2Link = entity.AUrl2Link; AUrl3 = entity.AUrl3; AUrl3Link = entity.AUrl3Link; IsNew = entity.IsNew; IsHome = entity.IsHome; IsOut = entity.IsOut; Vister = entity.Vister; Emailer = entity.Emailer; Printer = entity.Printer; MainCode = entity.MainCode; MainName = entity.MainName; AdminCode = entity.AdminCode; AdminName = entity.AdminName; ServiceCode = entity.ServiceCode; ServiceName = entity.ServiceName; Tag = entity.Tag; #endregion #region 英文欄位 NameENG = entity.NameENG; ContentENG = entity.ContentENG; Pic1ENG = entity.Pic1ENG; Pic1NameENG = entity.Pic1NameENG; Pic2ENG = entity.Pic2ENG; Pic2NameENG = entity.Pic2NameENG; Pic3ENG = entity.Pic3ENG; Pic3NameENG = entity.Pic3NameENG; AFile1ENG = entity.AFile1ENG; AFile1NameENG = entity.AFile1NameENG; AFile2ENG = entity.AFile2ENG; AFile2NameENG = entity.AFile2NameENG; AFile3ENG = entity.AFile3ENG; AFile3NameENG = entity.AFile3NameENG; AUrlENG = entity.AUrlENG; AUrl1ENG = entity.AUrl1ENG; AUrl1LinkENG = entity.AUrl1LinkENG; AUrl2ENG = entity.AUrl2ENG; AUrl2LinkENG = entity.AUrl2LinkENG; AUrl3ENG = entity.AUrl3ENG; AUrl3LinkENG = entity.AUrl3LinkENG; VisterENG = entity.VisterENG; EmailerENG = entity.EmailerENG; PrinterENG = entity.PrinterENG; #endregion if (entity.NewsClass != null) { NewsClass = entity.NewsClass; NewsClassId = entity.NewsClass.NewsClassId; } if (entity.NewsType != null) { NewsType = entity.NewsType; NewsTypeId = entity.NewsType.NewsTypeId; } } }
private void Save(News entity) { if (NewsClassId > 0) { entity.NewsClass = m_FTISService.GetNewsClassById(NewsClassId); } else { entity.NewsClass = null; } if (NewsTypeId > 0) { entity.NewsType = m_FTISService.GetNewsTypeById(NewsTypeId); } else { entity.NewsType = null; } #region 中文欄位 entity.Name = Name; entity.SortId = SortId; entity.Status = Status; entity.PostDate = PostDate; entity.Content = Content; entity.Pic1 = Pic1; entity.Pic1Name = Pic1Name; entity.Pic2 = Pic2; entity.Pic2Name = Pic2Name; entity.Pic3 = Pic3; entity.Pic3Name = Pic3Name; entity.AFile1 = AFile1; entity.AFile1Name = AFile1Name; entity.AFile2 = AFile2; entity.AFile2Name = AFile2Name; entity.AFile3 = AFile3; entity.AFile3Name = AFile3Name; entity.AUrl = AUrl; entity.AUrl1 = AUrl1; entity.AUrl1Link = AUrl1Link; entity.AUrl2 = AUrl2; entity.AUrl2Link = AUrl2Link; entity.AUrl3 = AUrl3; entity.AUrl3Link = AUrl3Link; entity.IsNew = IsNew; entity.IsHome = IsHome; entity.IsOut = IsOut; entity.Vister = Vister; entity.Emailer = Emailer; entity.Printer = Printer; entity.MainCode = MainCode; entity.MainName = MainName; entity.AdminCode = AdminCode; entity.AdminName = AdminName; entity.ServiceCode = ServiceCode; entity.ServiceName = ServiceName; entity.Tag = Tag; #endregion #region 英文欄位 entity.NameENG = NameENG; entity.ContentENG = ContentENG; entity.Pic1ENG = Pic1ENG; entity.Pic1NameENG = Pic1NameENG; entity.Pic2ENG = Pic2ENG; entity.Pic2NameENG = Pic2NameENG; entity.Pic3ENG = Pic3ENG; entity.Pic3NameENG = Pic3NameENG; entity.AFile1ENG = AFile1ENG; entity.AFile1NameENG = AFile1NameENG; entity.AFile2ENG = AFile2ENG; entity.AFile2NameENG = AFile2NameENG; entity.AFile3ENG = AFile3ENG; entity.AFile3NameENG = AFile3NameENG; entity.AUrlENG = AUrlENG; entity.AUrl1ENG = AUrl1ENG; entity.AUrl1LinkENG =AUrl1LinkENG; entity.AUrl2ENG = AUrl2ENG; entity.AUrl2LinkENG = AUrl2LinkENG; entity.AUrl3ENG = AUrl3ENG; entity.AUrl3LinkENG = AUrl3LinkENG; entity.VisterENG = VisterENG; entity.EmailerENG = EmailerENG; entity.PrinterENG = PrinterENG; #endregion if (entity.NewsId == 0) { m_FTISService.CreateNews(entity); } else { m_FTISService.UpdateNews(entity); } LoadEntity(entity.NewsId); }
public void Insert() { News entity = new News(); Save(entity); }
public void Test_News() { //新增 string newsClassName = "新增NewsClass測試234reeewwwww"; NewsClass newsClass = CreateNewsClass(newsClassName); string name = "新增News測試adfsfdfeee3vvvv"; News news = new News() { NewsClass = newsClass, LangId = "2", Name = name, PostDate = DateTime.Now, Content = "123", Pic1="Pic1", Pic2 = "Pic2", Pic3 = "Pic3", Pic1Name="Pic1Name", Pic2Name = "Pic2Name", Pic3Name = "Pic3Name", AFile1 = "AFile1", AFile2 = "AFile2", AFile3 = "AFile3", AFile1Name = "AFile1Name", AFile2Name = "AFile2Name", AFile3Name = "AFile3Name", AUrl1 = "AUrl1", AUrl2 = "AUrl2", AUrl3 = "AUrl3", AUrl1Link = "AUrl1Link", AUrl2Link = "AUrl2Link", AUrl3Link = "AUrl3Link", IsHome = "1", IsNew = "1", Vister = 1, Emailer = 2, Printer = 3, SortId = 250, Status = "1", MainCode ="200", MainName="MainName", AdminCode = "100", AdminName = "AdminName", ServiceCode = "300", ServiceName = "ServiceName", Tag = "Tag", IsOut = "1", AUrl = "AUrl" }; m_FTISService.CreateNews(news); Assert.AreNotEqual(0, news.NewsId); //更新 string updateName = "更新News測試535353533ddee"; News updateNews = m_FTISService.GetNewsByIdNoLazy(news.NewsId); Assert.AreEqual(name, updateNews.Name); Assert.AreEqual(newsClassName, updateNews.NewsClass.Name); updateNews.Name = updateName; m_FTISService.UpdateNews(updateNews); //查詢 IDictionary<string, string> conditions = new Dictionary<string, string>(); conditions.Add("KeyWord", updateName); conditions.Add("Status", "1"); conditions.Add("IsHome", "1"); IList<News> newsList = m_FTISService.GetNewsList(conditions); Assert.AreEqual(1, newsList.Count); Assert.AreEqual(1, m_FTISService.GetNewsCount(conditions)); Assert.AreEqual(updateName, newsList[0].Name); conditions = new Dictionary<string, string>(); conditions.Add("KeyWord", name); conditions.Add("Status", "1"); conditions.Add("IsHome", "1"); newsList = m_FTISService.GetNewsList(conditions); Assert.AreEqual(0, newsList.Count); Assert.AreEqual(0, m_FTISService.GetNewsCount(conditions)); conditions = new Dictionary<string, string>(); conditions.Add("KeyWord", updateName); conditions.Add("Status", "0"); conditions.Add("IsHome", "1"); newsList = m_FTISService.GetNewsList(conditions); Assert.AreEqual(0, newsList.Count); Assert.AreEqual(0, m_FTISService.GetNewsCount(conditions)); //刪除 m_FTISService.DeleteNews(updateNews); m_FTISService.DeleteNewsClass(newsClass); conditions = new Dictionary<string, string>(); conditions.Add("KeyWord", updateName); conditions.Add("Status", "1"); conditions.Add("IsHome", "1"); newsList = m_FTISService.GetNewsList(conditions); Assert.AreEqual(0, newsList.Count); Assert.AreEqual(0, m_FTISService.GetNewsCount(conditions)); ////查詢Tags string searchTags = "歐盟EuP,歐盟CLP"; conditions.Clear(); conditions.Add("Tags", searchTags); newsList = m_FTISService.GetNewsList(conditions); if (newsList != null && newsList.Count > 0) { foreach (News n in newsList) { string tags = n.Tag; } } //測試舊資料英文內容 News newsENG = m_FTISService.GetNewsById(7); Assert.IsNull(newsENG.NameENG); }