Beispiel #1
0
        /// <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();
        }
Beispiel #2
0
        /// <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;
            }
        }
Beispiel #3
0
        /// <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();
        }
Beispiel #4
0
 public static TagArticleEntity ToBllTagArticle(this DalTagArticle dalTagArticle)
 {
     if (dalTagArticle != null)
     {
         return(new TagArticleEntity()
         {
             Id = dalTagArticle.Id,
             ArticleId = dalTagArticle.ArticleId,
             TagId = dalTagArticle.TagId
         });
     }
     return(null);
 }