/// <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());
 }
 /// <summary>
 /// Set specified properties for existing comment.
 /// </summary>
 /// <param name="entity"></param>
 public void Update(DalComment entity)
 {
     if (entity == null)
         throw new ArgumentNullException(nameof(entity));
     Comment comment = context.Set<Comment>().Find(entity.Id);
     if (comment != null)
         comment.Message = entity.Message;
 }
コード例 #3
0
 public void Create(DalComment e)
 {
     var comment = new Comment()
     {
         TaskId=e.TaskId,
         UserId=e.UserId,
         Message=e.Message
     };
     context.Set<Comment>().Add(comment);
 }
 /// <summary>
 /// Remove specified comment from database.
 /// </summary>
 /// <param name="comment"></param>
 public void Delete(DalComment comment)
 {
     if (comment == null)
         throw new ArgumentNullException(nameof(comment));
     Comment commentInDB = context.Set<Comment>().Find(comment.Id);
     if (commentInDB != null)
     {
         context.Set<Comment>().Remove(commentInDB);
     }
 }
コード例 #5
0
 public void Delete(DalComment e)
 {
     var comment = new Comment()
     {
         CommentId = e.Id,
         TaskId=e.TaskId,
         UserId=e.UserId,
         Message=e.Message
     };
     comment = context.Set<Comment>().Single(c => c.CommentId == c.CommentId);
     context.Set<Comment>().Remove(comment);
 }
コード例 #6
0
 public void Update(DalComment e)
 {
     var comment = new Comment()
     {
         CommentId = e.Id,
         TaskId = e.TaskId,
         UserId = e.UserId,
         Message = e.Message
     };
     comment = context.Set<Comment>().Single(c => c.CommentId == comment.CommentId);
     context.Entry(comment).State = System.Data.Entity.EntityState.Modified;
     // throw new NotImplementedException();
 }
コード例 #7
0
 public static Comment ToOrmComment(this DalComment e)
 {
     return(new Comment()
     {
         Date = e.Date,
         Id = e.Id,
         Text = e.Text,
         User = e.User?.ToOrmUser(),
         Content = new Content()
         {
             Id = e.ContentId
         }
     });
 }
コード例 #8
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;
        }
コード例 #9
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);
 }
コード例 #10
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);
 }