/// <summary> /// Determination of removing entity /// </summary> /// <param name="entity">tag of article to delete</param> public void Delete(DalTagArticle entity) { var tagArticle = context.Set <TagArticle>().Where(s => s.Id == entity.Id).FirstOrDefault(); if (tagArticle != null) { context.Set <TagArticle>().Remove(tagArticle); } context.SaveChanges(); }
/// <summary> /// Update information about tag of article /// </summary> /// <param name="entity">tag of article to update</param> public void Update(DalTagArticle entity) { var tagArticle = context.Set <TagArticle>().Where(s => s.Id == entity.Id).FirstOrDefault(); if (tagArticle != null) { tagArticle.Id = entity.Id; tagArticle.ArticleId = entity.ArticleId; tagArticle.TagId = entity.TagId; } }
/// <summary> /// Adding tag for article /// </summary> /// <param name="entity"></param> public void Create(DalTagArticle entity) { var tagArticle = new TagArticle() { Id = entity.Id, ArticleId = entity.ArticleId, TagId = entity.TagId }; context.Set <TagArticle>().Add(tagArticle); context.SaveChanges(); }
public static TagArticleEntity ToBllTagArticle(this DalTagArticle dalTagArticle) { if (dalTagArticle != null) { return(new TagArticleEntity() { Id = dalTagArticle.Id, ArticleId = dalTagArticle.ArticleId, TagId = dalTagArticle.TagId }); } return(null); }