public void AddComment(int userId, string comment)
        {
            if (StringUtils.IsBlank(comment))
            {
                throw new ArgumentException("Comment cannot be blank");
            }

            OrderItemComment orderItemComment = OrderItemComment.New();

            orderItemComment.OrderItemId = OrderItemId.GetValueOrDefault();
            orderItemComment.UserId      = userId;
            orderItemComment.CommentText = comment;
            orderItemComment.CommentDate = DateTime.Now;
            NewOrderItemCommentList.Add(orderItemComment);
        }
Exemple #2
0
        protected override object ReadRow(IRowReader reader)
        {
            OrderItemComment orderItemComment = OrderItemComment.New();

            // Table Fields
            orderItemComment.OrderItemCommentId = reader.GetInt32("OrderItemCommentId");
            orderItemComment.OrderItemId        = reader.GetInt32("OrderItemId");
            orderItemComment.UserId             = reader.GetInt32("UserId");
            orderItemComment.CommentText        = reader.GetString("CommentText");
            orderItemComment.CommentDate        = reader.GetDateTime("CommentDate");

            // View Fields
            orderItemComment.UserFullName = reader.GetString("UserFullName");

            orderItemComment.IsDirty = false;
            orderItemComment.ChangedProperties.Clear();

            return(orderItemComment);
        }
Exemple #3
0
        public virtual OrderItemComment Update(OrderItemComment orderItemComment)
        {
            if (!orderItemComment.IsDirty || orderItemComment.IsNull)
            {
                // Nothing to do - no point hammering the database unnecessarily
                return(orderItemComment);
            }

            IDbCommand command = CreateCommand();

            if (orderItemComment.IsNew)
            {
                // Adding
                command.CommandText = "INSERT INTO [OrderItemComment] ([OrderItemId], [UserId], [CommentText], [CommentDate]) VALUES (@orderItemId, @userId, @commentText, @commentDate) ; SELECT @@identity AS NewId;";
            }
            else
            {
                // Updating
                command.CommandText = "UPDATE [OrderItemComment] SET [OrderItemId] = @orderItemId, [UserId] = @userId, [CommentText] = @commentText, [CommentDate] = @commentDate WHERE OrderItemCommentId = @orderItemCommentId";
            }

            command.Parameters.Add(CreateParameter("@orderItemId", orderItemComment.OrderItemId));
            command.Parameters.Add(CreateParameter("@userId", orderItemComment.UserId));
            command.Parameters.Add(CreateParameter("@commentText", orderItemComment.CommentText));
            command.Parameters.Add(CreateParameter("@commentDate", orderItemComment.CommentDate));

            if (orderItemComment.IsNew)
            {
                orderItemComment.OrderItemCommentId = Convert.ToInt32(ExecScalar(command));
            }
            else
            {
                command.Parameters.Add(CreateParameter("@orderItemCommentId", orderItemComment.OrderItemCommentId));
                ExecuteCommand(command);
            }

            orderItemComment.IsDirty = false;
            orderItemComment.ChangedProperties.Clear();

            return(orderItemComment);
        }
Exemple #4
0
        public static OrderItemComment FindOne(OrderItemCommentFinder finder)
        {
            OrderItemComment OrderItemComment = OrderItemCommentMapper.Instance.FindOne(finder);

            return(OrderItemComment ?? Empty);
        }
Exemple #5
0
 public static OrderItemComment Update(OrderItemComment orderItemComment)
 {
     return(OrderItemCommentMapper.Instance.Update(orderItemComment));
 }
Exemple #6
0
        public static OrderItemComment Get(Nullable <Int32> OrderItemCommentId)
        {
            OrderItemComment OrderItemComment = OrderItemCommentMapper.Instance.Get(OrderItemCommentId);

            return(OrderItemComment ?? Empty);
        }