Esempio n. 1
0
        public IHttpActionResult UpdateNewsItem(NewsItem newsItem)
        {
            PenOCDataContext db = new PenOCDataContext();

            tblNews newsItemRecord = db.tblNews.Single(n => n.idNews == newsItem.id);

            newsItemRecord.dteDate = newsItem.date;
            newsItemRecord.strTitle = newsItem.title;
            newsItemRecord.strNews = newsItem.news;

            db.SubmitChanges();

            return Ok(newsItem);
        }
Esempio n. 2
0
        public IHttpActionResult InsertNewsItem(NewsItem newsItem)
        {
            PenOCDataContext db = new PenOCDataContext();

            tblNews newsItemRecord = new tblNews
            {
                dteDate = newsItem.date,
                strTitle = newsItem.title,
                strNews = newsItem.news
            };

            db.tblNews.InsertOnSubmit(newsItemRecord);
            db.SubmitChanges();

            newsItem.id = newsItemRecord.idNews;

            return Ok(newsItem);
        }