public void TestAdd()
 {
     var comment = new Comment
                       {
                           Author = EmployeeWraper.GetSample(),
                           Content = "Test comment",
                           Created = (ApiDateTime) DateTime.UtcNow,
                           Deleted = false,
                           Key = "testkey",
                           Updated = null
                       };
     _repository.SaveOrUpdate(comment);
     Assert.AreNotEqual(comment.Id, 0);
     Comment retrieveComment = _repository.Get(comment.Id);
     Assert.AreEqual(comment.Id, retrieveComment.Id);
     Assert.AreEqual(comment.Content, retrieveComment.Content);
 }
 public Comment Delete(Comment comment)
 {
     Delete(comment.Id);
     comment.Deleted = true;
     return comment;
 }
 public Comment SaveOrUpdate(Comment comment)
 {
     using (DbManager dbMan = GetManager())
     {
         using (IDbTransaction transaction = dbMan.BeginTransaction(IsolationLevel.ReadUncommitted))
         {
             SqlInsert query = new SqlInsert(CommentTable, true)
                 .Identity(0, (Int64) 0, true)
                 .InColumns(SelectFields.Split(','))
                 .Values(comment.Id, comment.ParentId, comment.Content, comment.Author.Id.ToString(),
                         comment.Deleted,
                         comment.SecurityId, comment.Created.Utc ?? DateTime.UtcNow, DateTime.UtcNow, comment.Key);
             comment.Id = dbMan.ExecuteScalar<long>(query);
             //Mark comment as readed
             SqlInsert readedQuery =
                 new SqlInsert(CommentReadedTable).IgnoreExists(true).InColumns("comment_id", "user_id").Values(
                     comment.Id, comment.Author.Id.ToString());
             dbMan.ExecuteNonQuery(readedQuery);
             comment.Readed = DateTime.UtcNow;
             transaction.Commit();
         }
     }
     return comment;
 }