示例#1
0
 public void Save(NewsBlock newsBlock)
 {
     _entitiesSource.NewsBlocks.Attach(newsBlock);
     _entitiesSource.ObjectStateManager.ChangeObjectState(newsBlock, EntityState.Modified);
     newsBlock.Posted = DateTime.Now;
     _entitiesSource.SaveChanges();
 }
示例#2
0
        public static NewsBlock CreateNewsBlock(string title, List <NewsContent> newsContents = null)
        {
            var newsBlock = new NewsBlock(title);

            newsBlock.Set(NewsBlock.PropertyAccessExpressions.NewsContents, newsContents);

            return(newsBlock);
        }
示例#3
0
        public static NewsBlock CreateNewsBlock(string title, params string[] details)
        {
            var newsContents = details.Select((detail, i) => CreateNewsContent(i + 1, detail)).ToList();

            var newsBlock = new NewsBlock(title);

            newsBlock.Set(NewsBlock.PropertyAccessExpressions.NewsContents, newsContents);

            return(newsBlock);
        }
示例#4
0
        public ActionResult GetNewsStory()
        {
            var vm = new NewsBlock
            {
                Header = "From Server at " + DateTime.Now,
                Ptags  = new List <string>
                {
                    "hello",
                    "world"
                }
            };

            return(PartialView("_newBlock", vm));
        }
示例#5
0
 public void Create(NewsBlock newsItem)
 {
     var locals = Languages;
     newsItem.Posted = DateTime.Now;
     _entitiesSource.NewsBlocks.AddObject(newsItem);
     foreach (var local in locals)
     {
         newsItem.NewsBlockLocals.Add(new NewsBlockLocal { NewsBlock = newsItem, LangId = local.Id,
             Name = "News block new",
             Summary = "short summary",
             Body = String.Empty });
     }
     _entitiesSource.SaveChanges();
 }
示例#6
0
 public void Save(NewsBlock newsBlock)
 {
     _repository.Save(newsBlock);
 }
示例#7
0
 public void Save(NewsBlock newsBlock)
 {
     _context.NewsBlocks.Add(newsBlock);
     _context.SaveChanges();
 }