Esempio n. 1
0
        public void DeleteComment(DalComment e)
        {
            var comment = e.ToOrmComment();

            comment = context.Set <Comment>().Single(c => c.Id == comment.Id);
            context.Set <Comment>().Remove(comment);
        }
Esempio n. 2
0
        public void Update(DalComment entity)
        {
            var comment = _context.Set <Comment>().Single(c => c.Id == entity.Id);

            comment.Text = entity.Text;
            _context.Set <Comment>().AddOrUpdate(comment);
        }
Esempio n. 3
0
        public void Update(DalComment entity)
        {
            var filter = Builders <Comment> .Filter.Eq(u => u.Id, entity.Id);

            modelContext.Comments.ReplaceOne(filter, entity.ToOrmComment(), new UpdateOptions()
            {
                IsUpsert = true
            });
        }
        public void Delete(DalComment entity)
        {
            var dbComment = context.Comments.FirstOrDefault(e => e.CommentID == entity.ID);

            if (dbComment != null)
            {
                context.Comments.Remove(dbComment);
            }
        }
        public void Update(DalComment entity)
        {
            var comment = _context.Comments.FirstOrDefault(x => x.Id == entity.Id);

            if (comment != null)
            {
                comment.Text = entity.Text;
            }
        }
        public void Delete(DalComment e)
        {
            var comment = _context.Comments.FirstOrDefault(x => x.Id == e.Id);

            if (comment != null)
            {
                _context.Comments.Remove(comment);
            }
        }
Esempio n. 7
0
        public void AddComment(DalComment e)
        {
            var comment = e.ToOrmComment();

            comment.Date    = DateTime.Now;
            comment.User    = context.Set <User>().Find(e.User.Id);
            comment.Content = context.Set <Content>().Find(e.ContentId);
            context.Set <Comment>().Add(comment);
        }
Esempio n. 8
0
 /// <summary>
 /// Create new comment and add it to database.
 /// </summary>
 /// <param name="comment"></param>
 public void Create(DalComment comment)
 {
     if (comment == null)
     {
         throw new ArgumentNullException(nameof(comment));
     }
     comment.CreationDateTime = DateTime.Now;
     context.Set <Comment>().Add(comment.ToOrmComment());
 }
Esempio n. 9
0
        /// <summary>
        /// Deletes comment entity
        /// </summary>
        /// <param name="e">Base entity for removing</param>
        public void Delete(DalComment e)
        {
            var comment = context.Set <Comment>().Where(a => a.Id == e.Id).FirstOrDefault();

            if (comment != null)
            {
                context.Set <Comment>().Remove(comment);
            }
            //context.Set<Comment>().Remove(e.ToOrmComment());
        }
Esempio n. 10
0
        public void Delete(DalComment e)
        {
            var comment = context.Set <Comment>().Where(a => a.Id == e.Id).FirstOrDefault();

            if (comment != null)
            {
                context.Set <Comment>().Remove(comment);
            }
            context.SaveChanges();
        }
Esempio n. 11
0
 public static BllComment ToBll(this DalComment comment)
 {
     return(new BllComment
     {
         Id = comment.Id,
         Content = comment.Content,
         PostId = comment.PostId,
         UserId = comment.UserId
     });
 }
Esempio n. 12
0
 public static CommentEntity ToBllComment(this DalComment dalComment)
 {
     return(new CommentEntity()
     {
         Id = dalComment.Id,
         PostId = dalComment.PostId,
         UserId = dalComment.UserId,
         Text = dalComment.Text
     });
 }
Esempio n. 13
0
 public static Comment ToOrmComment(this DalComment e)
 {
     return(new Comment()
     {
         Id = e.Id,
         DateTime = e.DateTime,
         Text = e.Text,
         UserId = e.UserId,
         ArticleId = e.ArticleId
     });
 }
Esempio n. 14
0
 public static BllComment ToBllComment(this DalComment comment)
 {
     return(new BllComment()
     {
         CommentId = comment.Id,
         CreationDate = comment.CreationDate,
         Text = comment.Text,
         Author = comment.Author?.ToBllUser(),
         Article = comment.Article?.ToBllArticle()
     });
 }
Esempio n. 15
0
        public void UpdateComment(DalComment comment)
        {
            var original = context.Set <Comment>().First(u => u.Id == comment.Id);

            var updatedComment = comment.ToOrmComment();

            if (updatedComment.Text != null)
            {
                original.Text = updatedComment.Text;
            }
        }
Esempio n. 16
0
 public static Comment ToOrmComment(this DalComment dalComment)
 {
     return(new Comment()
     {
         CommentId = dalComment.Id,
         Description = dalComment.Description,
         DateOfSending = dalComment.DateOfSending,
         PhotoId = dalComment.PhotoId,
         UserId = dalComment.UserId
     });
 }
Esempio n. 17
0
 public static BllComment ToBllComment(this DalComment comment)
 {
     return(new BllComment()
     {
         Id = comment.Id,
         Author = comment.Author.ToBllAuthor(),
         PhotoId = comment.PhotoId,
         Posted = comment.Posted,
         Text = comment.Text
     });
 }
Esempio n. 18
0
 public static Comments ToOrmComment(this DalComment comment)
 {
     return(new Comments
     {
         Added_Date = comment.PublishTime,
         CommentID = comment.ID,
         BookID = comment.BookID,
         UserID = comment.UserID,
         Text = comment.Text
     });
 }
Esempio n. 19
0
 public static Task <CommentEntity> ToBllCommentTask(this DalComment dalComment)
 {
     return(new Task <CommentEntity>(() => new CommentEntity()
     {
         Id = dalComment.Id,
         Name = dalComment.Name,
         Description = dalComment.Description,
         PostId = dalComment.PostId,
         CreatedOn = dalComment.CreatedOn
     }));
 }
 public static ServiceComment ToServiceComment(this DalComment comment)
 {
     return(new ServiceComment
     {
         ID = comment.ID,
         BookID = comment.BookID,
         UserID = comment.UserID,
         Text = comment.Text,
         PublishTime = comment.PublishTime,
     });
 }
Esempio n. 21
0
 public static CommentEntity ToCommentEntity(this DalComment comment)
 {
     return(new CommentEntity()
     {
         Id = comment.Id,
         DateTime = comment.DateTime,
         Text = comment.Text,
         UserId = comment.UserId,
         ArticleId = comment.ArticleId
     });
 }
Esempio n. 22
0
 public static CommentEntity ToBllComment(this DalComment dalComment)
 {
     return(new CommentEntity()
     {
         Id = dalComment.Id,
         Name = dalComment.Name,
         Description = dalComment.Description,
         PostId = dalComment.PostId,
         CreatedOn = dalComment.CreatedOn
     });
 }
Esempio n. 23
0
 public static FullCommentEntity ToFullCommentEntity(this DalComment comment)
 {
     return(new FullCommentEntity()
     {
         Id = comment.Id,
         DateTime = comment.DateTime,
         Text = comment.Text,
         User = comment.User?.ToBllUser(),
         ArticleId = comment.ArticleId
     });
 }
        public int Create(DalComment entity)
        {
            var dbBook = context.Books.FirstOrDefault(e => e.BookID == entity.BookID);
            var dbUser = context.Users.FirstOrDefault(e => e.UserID == entity.UserID);

            if (dbBook != null && dbUser != null)
            {
                context.Comments.Add(entity.ToOrmComment());
            }
            return(0);
        }
Esempio n. 25
0
 public static CommentEntity ToBllComment(this DalComment e)
 {
     return(new CommentEntity()
     {
         Date = e.Date,
         Id = e.Id,
         Text = e.Text,
         User = e.User.ToBllUser(),
         ContentId = e.ContentId
     });
 }
        public void Delete(DalComment entity)
        {
            var comment = new Comment()
            {
                Description = entity.Description,
                CreatedOn   = entity.CreatedOn,
                Name        = entity.Name
            };

            comment = context.Set <Comment>().Single(cmnt => cmnt.Id == entity.Id);
            context.Set <Comment>().Remove(comment);
        }
        public void Create(DalComment entity)
        {
            var comment = new Comment()
            {
                Description = entity.Description,
                Name        = entity.Name,
                CreatedOn   = entity.CreatedOn,
                PostId      = entity.PostId
            };

            context.Set <Comment>().Add(comment);
        }
Esempio n. 28
0
 public static CommentEntity ToBllComment(this DalComment dalComment)
 {
     return(dalComment == null ? null : new CommentEntity
     {
         Id = dalComment.Id,
         Text = dalComment.Text,
         Date = dalComment.Date,
         User = dalComment.User.ToBllUser(),
         Lot = dalComment.Lot.ToBllLot(),
         LotId = dalComment.LotId,
         UserId = dalComment.UserId
     });
 }
Esempio n. 29
0
        public static DalComment ToDalComment(this CommentEntity commentEntity)
        {
            DalComment newComment = new DalComment
            {
                Id     = commentEntity.Id,
                Text   = commentEntity.Text,
                Date   = commentEntity.Date,
                LotId  = commentEntity.LotId,
                UserId = commentEntity.UserId
            };

            return(newComment);
        }
Esempio n. 30
0
 public static BllComment ToBllComment(this DalComment dalComment)
 {
     return(new BllComment
     {
         Id = dalComment.Id,
         Text = dalComment.Text,
         Date = dalComment.Date,
         IsAnswer = dalComment.IsAnswer,
         Topic = dalComment.Topic.ToBllTopic(),
         Sender = dalComment.Sender?.ToBllUser(),
         Status = dalComment.Status.ToBllStatus()
     });
 }
 public static DalComment ToDalComment(this FullCommentEntity fullComment)
 {
     DalComment comment = new DalComment()
     {
         Id = fullComment.Id,
         DateTime = fullComment.DateTime,
         Text = fullComment.Text,
         ArticleId = fullComment.ArticleId
     };
     if (fullComment.User != null)
         comment.UserId = fullComment.User.Id;
     return comment;
 }