Beispiel #1
0
 public void AddEntry(NewsEntryData entry)
 {
     if (!_entries.Contains(entry))
     {
         _entries.Add(entry);
     }
 }
        public void Load()
        {
            try
            {
                if (!_dbContext.News.Any())
                {
                    return;
                }

                foreach (DAL.Models.News news in _dbContext.News)
                {
                    var newNews = new NewsData(news.Id)
                    {
                        Name      = news.Name,
                        Header    = news.Header,
                        Level     = news.Level,
                        CreatedBy = news.CreatedBy,
                        CreatedOn = news.CreatedOn,
                        Active    = news.IsActive
                    };
                    News.ToList().Add(newNews);

                    foreach (DAL.Models.NewsEntry entry in news.Entries)
                    {
                        var newEntry = new NewsEntryData
                        {
                            Id       = entry.Id,
                            Title    = entry.Title,
                            Name     = entry.Name,
                            Text     = entry.Text,
                            PostedOn = entry.PostedOn,
                            PostedBy = entry.PostedBy,
                            Active   = entry.IsActive
                        };
                        newNews.Entries.ToList().Add(newEntry);
                    }
                }
                _logManager.Boot("Loaded {0} News", News.Count());
            }
            catch (DbException ex)
            {
                _logManager.Error(ex);
                throw;
            }
        }