Ejemplo n.º 1
0
        //string subject, string content, ImageTypes imageType, byte[] imageData
        public bool EditNews(News newsItem)
        {
            bool success = false;

            News article = db.News.Where(x => x.NewsID == newsItem.NewsID).SingleOrDefault();
            article.Subject = newsItem.Subject;
            article.Content = newsItem.Content;
            article.ImageType = newsItem.ImageType;
            article.ArticleTypeID = newsItem.ArticleTypeID;

            db.SubmitChanges();

            return success;
        }
Ejemplo n.º 2
0
        //TODO: Remove Version from Service
        public string FormatArticleForIPhone(News article, string htmlFormat, string errorFormat)
        {
            string formattedArticle = String.Empty;
            if (article != null)
            {
                formattedArticle = htmlFormat.Replace("[ARTICLE_HEADER]", article.Subject);
                formattedArticle = formattedArticle.Replace("[ARTICLE_TITLE]", article.DateTime.ToString("MMMMM dd, yyyy"));
                formattedArticle = formattedArticle.Replace("[ARTICLE_CONTENT]", article.Content);
            }
            else
            {
                formattedArticle = errorFormat;
            }

            return formattedArticle;
        }
 partial void DeleteNews(News instance);
 partial void UpdateNews(News instance);
 partial void InsertNews(News instance);
Ejemplo n.º 6
0
 public News()
 {
     d_News = new DAL.News();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the News EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNews(News news)
 {
     base.AddObject("News", news);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Create a new News object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="content">Initial value of the Content property.</param>
 /// <param name="insertedDate">Initial value of the InsertedDate property.</param>
 /// <param name="thumbnailUrl">Initial value of the ThumbnailUrl property.</param>
 /// <param name="sectionsId">Initial value of the SectionsId property.</param>
 /// <param name="providersId">Initial value of the ProvidersId property.</param>
 /// <param name="hasVideo">Initial value of the HasVideo property.</param>
 public static News CreateNews(global::System.Int32 id, global::System.String title, global::System.String content, global::System.DateTime insertedDate, global::System.String thumbnailUrl, global::System.Int32 sectionsId, global::System.Int32 providersId, global::System.Boolean hasVideo)
 {
     News news = new News();
     news.Id = id;
     news.Title = title;
     news.Content = content;
     news.InsertedDate = insertedDate;
     news.ThumbnailUrl = thumbnailUrl;
     news.SectionsId = sectionsId;
     news.ProvidersId = providersId;
     news.HasVideo = hasVideo;
     return news;
 }
Ejemplo n.º 9
0
        public News GetNewsArticle(int articleID)
        {
            var newsArticle = (from newsRecord in db.News
                               where newsRecord.NewsID == articleID
                               select newsRecord);

            if (newsArticle == null || newsArticle.Count() != 1)
            {
                //uh. Somethign bad happened
                //TODO: Record error
                News defaultNews = new News() { NewsID = -1, Content = "", DateTime = DateTime.Now, ImageType = (int)ImageTypes.General, ImageData = new byte[0], Subject = "Error" };
                return defaultNews;
            }

            News returnArticle = newsArticle.SingleOrDefault();

            return returnArticle;
        }
Ejemplo n.º 10
0
        public bool InsertNews(string subject, string content, ArticleTypes articleType, ImageTypes imageType, byte[] imageData)
        {
            bool success = false;

            News newArticle = new News();
            newArticle.DateTime = DateTime.Now;
            newArticle.Subject = subject;
            newArticle.Content = content;
            newArticle.ImageType = (int)imageType;
            newArticle.ArticleTypeID = (int)articleType;

            if (imageData.Length > 0)
            {
                newArticle.ImageData = ImageHelper.ResizeImage(imageData, 250, 150);
            }
            else
            {
                newArticle.ImageData = imageData;
            }

            db.News.InsertOnSubmit(newArticle);
            db.SubmitChanges();

            return success;
        }