public static void Execute(IDbConnection connection, BookOrderLineConflictDto bookOrderLineConflictDto) { connection.Execute("INSERT INTO book_order_line_conflicts (" + "id, " + "order_id, " + "order_line_id, " + "conflict_type," + "conflict_value, " + "accepted," + "created_datetime) " + "VALUES (?id, ?orderId, ?orderLineId, ?conflictType," + "?conflictValue," + "?accepted," + "?createdDateTime)", new { id = bookOrderLineConflictDto.Id, orderId = bookOrderLineConflictDto.Order_Id, orderLineId = bookOrderLineConflictDto.Order_Line_Id, conflictType = bookOrderLineConflictDto.conflict_type, conflictValue = bookOrderLineConflictDto.Conflict_Value, accepted = bookOrderLineConflictDto.Accepted, createdDateTime = bookOrderLineConflictDto.Created_DateTime }); }
internal static BookOrderLineConflictDto ToDto(this BookOrderLineConflict bookOrderLineConflict) { BookOrderLineConflictDto dto = new BookOrderLineConflictDto() { Id = bookOrderLineConflict.Id, conflict_type = bookOrderLineConflict.ConflictType.ToString(), Order_Id = bookOrderLineConflict.BookOrderId, Order_Line_Id = bookOrderLineConflict.BookOrderLineId, Conflict_Value = bookOrderLineConflict.ConflictValue, Accepted = bookOrderLineConflict.Accepted, Created_DateTime = bookOrderLineConflict.CreatedDateTime }; return(dto); }
public BookOrderLineConflict Get(Guid id) { BookOrderLineConflictDto dto = null; using (var connection = CreateConnection()) { connection.Open(); using (var transaction = connection.BeginTransaction()) { dto = GetBookOrderLineConflictsByIdAction.Execute(connection, id); transaction.Commit(); } } return(dto?.ToEntity()); }
internal static BookOrderLineConflict ToEntity(this BookOrderLineConflictDto dto) { if (dto.conflict_type.Equals("Quantity")) { int quantity = Convert.ToInt32(dto.Conflict_Value); return(BookOrderLineQuantityConflict.CreateExisting(dto.Id, dto.Order_Id, dto.Order_Line_Id, quantity, dto.Accepted, dto.Created_DateTime)); } else if (dto.conflict_type.Equals("Price")) { decimal price = Convert.ToDecimal(dto.Conflict_Value); return(BookOrderLinePriceConflict.CreateExisting( dto.Id, dto.Order_Id, dto.Order_Line_Id, price, dto.Accepted, dto.Created_DateTime)); } throw new ArgumentOutOfRangeException(); }