public static DalArticle ToDalArticle(this ArticleEntity blogEntity) { var dalArt = new DalArticle() { Id = blogEntity.Id, TimeAdded = blogEntity.DateAdded, Title = blogEntity.Name, BlogId = blogEntity.BlogId, Content = blogEntity.Content, ImagePath = blogEntity.ImagePath, }; if (!string.IsNullOrEmpty(blogEntity.Tags)) { dalArt.Tags = new List<Tag>(); var tagsArray = blogEntity.Tags.Split(','); foreach (var tag in tagsArray) { dalArt.Tags.Add(new Tag(tag)); } } return dalArt; }
public void Update(DalArticle entity) { var propertyContent = typeof(Article).GetProperty("Content"); var article = _context.Set<Article>().Find(entity.Id); propertyContent.SetValue(article, entity.Content); _context.SaveChanges(); }
public void Create(DalArticle e) { var art = new Article() { Title = e.Title, TimeAdded = DateTime.Now, BlogId = e.BlogId, Content = e.Content, ImagePath = e.ImagePath, Tags = e.Tags }; _context.Set<Article>().Add(art); _context.SaveChanges(); }