コード例 #1
0
 public List<Database.DTO.ArticleDto> List()
 {
     using (var db = new ArticleContext())
     {
         return db.Articles
             .Select(article => new Database.DTO.ArticleDto()
             {
                 Id = article.Id,
                 Path = article.Path,
                 Header = article.Header,
                 Category = article.Category
             }
             /*Service.Mappers.ArticleMapper.ConvertToDto(article)*/)
             .ToList();
     }
 }
コード例 #2
0
 public Database.DTO.ArticleDto Get(int id)
 {
     using (var db = new ArticleContext())
     {
         return db.Articles
             .Select(article => new Database.DTO.ArticleDto()
             {
                 Id = article.Id,
                 Path = article.Path,
                 Header = article.Header,
                 Category = article.Category
             }
             /*Service.Mappers.ArticleMapper.ConvertToDto(article)*/)
             .First(a => a.Id == id);
     }
 }
コード例 #3
0
        public void Update(Models.Article article)
        {
            using (var db = new ArticleContext())
            {
                var newarticle = db.Articles.First(a => a.Id == article.Id);

                newarticle.Header = article.Header;
                newarticle.Category = article.Category;

                db.SaveChanges();

            }
        }
コード例 #4
0
 /* Evt. burde vi at lave en fil der hedder Mediator (ikke i en mappe der hedder article)
     og så kan vi lave forskellige klasse i.e. articlemediator categorymediator */
 public List<Models.Category> GetAllCategories()
 {
     using (var db = new ArticleContext())
     {
         return db.Categories.ToList();
     }
 }
コード例 #5
0
 public void Save(Models.Article article)
 {
     using (var db = new ArticleContext())
     {
         db.Articles.Add(article);
         db.SaveChanges();
     }
 }