当前位置: 首页>>代码示例>>C#>>正文


C# News类代码示例

本文整理汇总了C#中News的典型用法代码示例。如果您正苦于以下问题:C# News类的具体用法?C# News怎么用?C# News使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


News类属于命名空间,在下文中一共展示了News类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateNews

        public IHttpActionResult CreateNews([FromBody]NewsBindingModel model)
        {
            if (model == null)
            {
                return this.BadRequest("Model cannot be null.");
            }

            if (!this.ModelState.IsValid)
            {
                return this.BadRequest("Missing parameters.");
            }

            var userId = this.User.Identity.GetUserId();

            var news = new News()
            {
                Title = model.Title,
                Content = model.Content,
                PublishDate = model.PublishDate,
                AuthorId = userId
            };

            this.repo.Add(news);

            this.repo.SaveChanges();

            return this.Content(HttpStatusCode.Created, news);
        }
开发者ID:Gleomit,项目名称:WebServicesAndCloud,代码行数:28,代码来源:NewsController.cs

示例2: btnGen_Click

    protected void btnGen_Click(object sender, EventArgs e)
    {
        try
        {
            NewsListInfo list = new NewsListInfo();
            foreach (GridViewRow row in gvList.Rows)
            {
                CheckBox cbSel = row.FindControl("cbSel") as CheckBox;
                string id = cbSel.Attributes["value"];
                NewsInfo nInfo = new News().GetByID(id);
                if (cbSel.Checked == true)
                {
                    PicNewsInfo pInfo = new PicNewsInfo();
                    pInfo.Summary = nInfo.Summary;
                    pInfo.Url = this.SiteUrl + "Browse.aspx?id=" + id;
                    pInfo.Title = nInfo.Title;
                    string content = nInfo.Content;
                    int imgStart = content.IndexOf("<img");
                    int srcStart = content.IndexOf("src", imgStart);
                    int start = content.IndexOf("UploadFiles/", srcStart);
                    int end = content.IndexOf("\"", start);

                    pInfo.FilePath = content.Substring(start, end - start);
                    list.List.Add(pInfo);
                }
            }
            Save(list);
            ShowMsg("图片新闻生成成功。");
        }
        catch (Exception ex)
        {
            ShowMsg("生成出错:" + ex.Message);
            LogEntry.Log.Write(ex.ToString(), EventLogEntryType.Error, LogSourceType.一般错误);
        }
    }
开发者ID:shanfree,项目名称:SharpReport,代码行数:35,代码来源:PicNewsManage.aspx.cs

示例3: ShowFile

    public void ShowFile(int newsID)
    {
        News objnews = new News();
        DataTable dt = objnews.GetAllNews(newsID, null, null, null, null);
        switch (dt.Rows[0]["FilePath"].ToString().ToLower())
        {
            case "doc":
            case "docx":
                Response.AddHeader("content-disposition", "attachment;filename=News Details" + dt.Rows[0]["NewsID"].ToString() + ".doc");
                break;
            case "xls":
                Response.AddHeader("content-disposition", "attachment;filename=News Details" + dt.Rows[0]["NewsID"].ToString() + ".xls");
                break;
            case "xlsx":
                Response.AddHeader("content-disposition", "attachment;filename=News Details" + dt.Rows[0]["NewsID"].ToString() + ".xlsx");
                break;
            case "pdf":
                Response.AddHeader("content-disposition", "attachment;filename=News Details" + dt.Rows[0]["NewsID"].ToString() + ".pdf");
                break;

        }

        Response.Charset = "";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = dt.Rows[0]["FileContentType"].ToString();
        Response.BinaryWrite((byte[])(dt.Rows[0]["FileData"]));

        Response.End();
    }
开发者ID:menasbeshay,项目名称:ivalley-svn,代码行数:29,代码来源:Login.aspx.cs

示例4: EditNews

        public static dynamic EditNews(News newsmodel)
        {
            using (DeneysanContext db = new DeneysanContext())
            {
                try
                {
                    News record = db.News.Where(d => d.NewsId == newsmodel.NewsId && d.Deleted == false).SingleOrDefault();
                    if (record != null)
                    {
                        record.Header = newsmodel.Header;
                        record.Language = newsmodel.Language;
                        record.Content = newsmodel.Content;
                        if (!string.IsNullOrEmpty(newsmodel.NewsImage))
                        {
                            record.NewsImage = newsmodel.NewsImage;
                        }
                        record.PageSlug = newsmodel.PageSlug;
                        record.TimeUpdated = DateTime.Now;
                        record.Spot = newsmodel.Spot;

                        db.SaveChanges();
                        return true;
                    }
                    else
                        return false;

                }
                catch (Exception ex)
                {
                    return false;
                }
            }
        }
开发者ID:cemelma,项目名称:argem,代码行数:33,代码来源:NewsManager.cs

示例5: rpNews_ItemCommand

    protected void rpNews_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        Label lblID = (Label)e.Item.FindControl("lblID");

        string strCommand = e.CommandName;
        int nID =ConvertData.ConvertToInt(lblID.Text);
        News objNews = new News();
        int nStatus = 0;
        switch (strCommand)
        {
            case "Delete":
                objNews.LoadById(nID);
                Support.DeleteFile("image", objNews.Data.Image);
                int nDelete = objNews.DeleteById(nID);

                BindDataToRepeater(1);
                break;

            case "Edit":
                 string sEdit = Constants.ROOT + Pages.BackEnds.ADMIN + "?" + Constants.PAGE + "=" + Pages.BackEnds.STR_NEWS_ADD + "&" + Constants.ACTION + "=" + Constants.ACTION_EDIT + "&" + Constants.ACTION_ID + "=" + nID;
                Response.Redirect(sEdit);
                break;

            case "Active":
                nStatus = objNews.UpdateStatus(nID, Constants.STATUS_INACTIVE);

                BindDataToRepeater(1);
                break;
            case "Inactive":
                nStatus = objNews.UpdateStatus(nID, Constants.STATUS_ACTIVE);

                BindDataToRepeater(1);
                break;
        }
    }
开发者ID:changtraicantinh,项目名称:atpgroup,代码行数:35,代码来源:NewsMain.ascx.cs

示例6: ToEntity

 public News ToEntity()
 {
     var news = new News();
     ModelObjectHelper.CopyObject(this,news);
     news.UrlTitle = StringHelper.VNSignedToLowerUnsigned(news.Title);
     return news;
 }
开发者ID:meothailand,项目名称:GKNMShop,代码行数:7,代码来源:NewsModel.cs

示例7: Save

        public void Save()
        {
            string newsTitle = txtNewsTitle.Text;
            string newsDescription = txtNewsDescription.Text;

            News news = new News();
            news.IsNew = true;
            news.NewsTitle = newsTitle;
            news.NewsDescription = newsDescription;
            news.Save();

            //Now Save Picture As Well..
            string result = UploadPrintableFile(news);
            if (result.Equals(""))
            {
                divStatusError.Visible = false;
                divStatusSuccess.Visible = true;
                lblStatusSuccess.Text = Global.SuccessLabelStatus;
                //lblStatusSuccess.ForeColor = System.Drawing.Color.Green;
            }
            else
            {
                divStatusSuccess.Visible = false;
                divStatusError.Visible = true;
                labelStatusError.Text = Global.ErrorLabelStatus + result;
                //labelStatusError.ForeColor = System.Drawing.Color.Red;
            }
            ClearForm();
        }
开发者ID:zaheerahmad,项目名称:Admin,代码行数:29,代码来源:ctlAddNews.ascx.cs

示例8: Add

 public static void Add(News news)
 {
     using (var connect = CreateTableConnection())
     {
         connect.InsertOrReplace(news);
     }
 }
开发者ID:startewho,项目名称:CnBetaUWA,代码行数:7,代码来源:NewsDataTable.cs

示例9: Add

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(News.Model.HKSJ_Relationship model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into HKSJ_Relationship(");
            strSql.Append("Address,Zip,plane,Fax,QQ_MSN,Date,people)");
            strSql.Append(" values (");
            strSql.Append("@Address,@Zip,@plane,@Fax,@QQ_MSN,@Date,@people)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@Address", SqlDbType.VarChar,50),
                    new SqlParameter("@Zip", SqlDbType.VarChar,20),
                    new SqlParameter("@plane", SqlDbType.VarChar,20),
                    new SqlParameter("@Fax", SqlDbType.VarChar,20),
                    new SqlParameter("@QQ_MSN", SqlDbType.VarChar,30),
                    new SqlParameter("@Date", SqlDbType.DateTime),
                    new SqlParameter("@people", SqlDbType.VarChar,20)};
            parameters[0].Value = model.Address;
            parameters[1].Value = model.Zip;
            parameters[2].Value = model.plane;
            parameters[3].Value = model.Fax;
            parameters[4].Value = model.QQ_MSN;
            parameters[5].Value = model.Date;
            parameters[6].Value = model.people;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
开发者ID:RunningStudent,项目名称:MyLearningCode_CSharp,代码行数:37,代码来源:HKSJ_Relationship.cs

示例10: Add

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(News.Model.HKSJ_Employees model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into HKSJ_Employees(");
            strSql.Append("title,content,people,date,status,MainPeople)");
            strSql.Append(" values (");
            strSql.Append("@title,@content,@people,@date,@status,@MainPeople)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@title", SqlDbType.VarChar,200),
                    new SqlParameter("@content", SqlDbType.NText),
                    new SqlParameter("@people", SqlDbType.VarChar,30),
                    new SqlParameter("@date", SqlDbType.DateTime),
                    new SqlParameter("@status", SqlDbType.Int,4),
                    new SqlParameter("@MainPeople", SqlDbType.VarChar,20)};
            parameters[0].Value = model.title;
            parameters[1].Value = model.content;
            parameters[2].Value = model.people;
            parameters[3].Value = model.date;
            parameters[4].Value = model.status;
            parameters[5].Value = model.MainPeople;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
开发者ID:RunningStudent,项目名称:MyLearningCode_CSharp,代码行数:35,代码来源:HKSJ_Employees.cs

示例11: ListNews_NonEmptyDb_ShouldReturn_OkListNews

        public void ListNews_NonEmptyDb_ShouldReturn_OkListNews()
        {
            var context = new NewsContext();
            var news1 = new News
            {
                Title = "Some new title 1.",
                Content = "Some freaky content.",
                PublishedDate = DateTime.Now
            };
            
            var news2 = new News
            {
                Title = "Some new title 2.",
                Content = "Some freaky content.",
                PublishedDate = DateTime.Now.AddDays(-10)
            };
            context.News.Add(news1);
            context.News.Add(news2);
            context.SaveChanges();

            var httpResponse = this.httpClient.GetAsync(NewsRequestUri).Result;
            var news = httpResponse.Content.ReadAsAsync<List<News>>().Result;
            
            Assert.AreEqual(httpResponse.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(news.Count, 2);
            Assert.AreEqual(news[0].Title, news1.Title);
            Assert.AreEqual(news[1].PublishedDate.ToString(), news2.PublishedDate.ToString());
        }
开发者ID:StefanBratovanov,项目名称:WebSevicesAndCloud,代码行数:28,代码来源:NewsControllerIntegrationTests.cs

示例12: LoadData

    private void LoadData()
    {
        int nItemID = ConvertData.ConvertToInt(Request.QueryString[Constants.NEWS_ID]);
        int ncat = ConvertData.ConvertToInt(Request.QueryString["ncat"]);

        if (ncat == 2)
        {
            lblNewAnothor.Text = "Các dịch vụ khác ";
        }
        int nIDCat = ConvertData.ConvertToInt(Request.QueryString["ncat"]);
        if (nIDCat!=2)
        {
            nIDCat = 1;
        }

        News objNews = new News();
        objNews.LoadById(nItemID);

        if (nItemID == 0)
        {
            string sURL = Constants.ROOT + Pages.FrontEnds.HOME;
            Response.Redirect(sURL);
        }
        else
        {
            lblTitle.Text = objNews.Data.Title;
            //lblInitContent.Text = objNews.Data.InitContent;
            ltrContent.Text = objNews.Data.MainContent;
        }

        DataTable dtb = new DataTable();
        dtb = objNews.Search(5, nItemID, "", nIDCat, EnumeType.ACTIVE, CurrentPageIndex, nPageSize, ref nPageCount);
        rptRelatedNews.DataSource = dtb;
        rptRelatedNews.DataBind();
    }
开发者ID:changtraicantinh,项目名称:atpgroup,代码行数:35,代码来源:NewDetails.ascx.cs

示例13: OnAdd

 public void OnAdd(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         if (ddlNews.SelectedValue == "-1")
         {
             using (DBDataContext db = new DBDataContext())
             {
                 var news = new News()
                 {
                     Header = txtHeader.Text.Trim(),
                     PageHeader = txtPageTitle.Text.Trim(),
                     Content = fckEditor.Value
                 };
                 db.News.InsertOnSubmit(news);
                 db.SubmitChanges();
                 lblMessage.Text = string.Format("Добавлена новая новость '{0}'", txtHeader.Text.Trim());
             }
         }
         else
         {
             Update();
         }
         InitLists();
     }
 }
开发者ID:Tigrifer,项目名称:KemConsult,代码行数:26,代码来源:News.aspx.cs

示例14: AddNews

 public ActionResult AddNews(News newsmodel,HttpPostedFileBase uploadfile,string txtdate)
 {
     var languages = LanguageManager.GetLanguages();
     var list = new SelectList(languages, "Culture", "Language");
     ViewBag.LanguageList = list;
     if (ModelState.IsValid)
     {
         if (uploadfile != null && uploadfile.ContentLength > 0)
         {
             Random random = new Random();
             int rand = random.Next(1000, 99999999);
             new ImageHelper(280, 240).SaveThumbnail(uploadfile, "/Content/images/news/", Utility.SetPagePlug(newsmodel.Header) + "_" + rand + Path.GetExtension(uploadfile.FileName));
             newsmodel.NewsImage = "/Content/images/news/" + Utility.SetPagePlug(newsmodel.Header) + "_" + rand + Path.GetExtension(uploadfile.FileName);
         }
         else
         {
             newsmodel.NewsImage = "/Content/images/front/noimage.jpeg";
         }
         newsmodel.PageSlug = Utility.SetPagePlug(newsmodel.Header);
         newsmodel.TimeCreated = Utility.ControlDateTime(txtdate);
         ViewBag.ProcessMessage = NewsManager.AddNews(newsmodel);
         ModelState.Clear();
        // Response.Redirect("/yonetim/haberduzenle/" + newsmodel.NewsId);
         return View();
     }
     else          
         return View();
 }
开发者ID:miyamotomusashi,项目名称:argemsan,代码行数:28,代码来源:NewsController.cs

示例15: ShowAddWindow

 public void ShowAddWindow()
 {
     this.Title = "平台公告新增";
     news = new  News();
     this.dataForm1.CurrentItem = news;
     base.Show();
 }
开发者ID:dalinhuang,项目名称:my-un-code,代码行数:7,代码来源:ChangeNews.xaml.cs


注:本文中的News类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。