public void ShouldBeAbleToStoreMultipleConflictsAndRetrieveUsingGetAll() { var sut = CreateSut(); var bookOrderLineConflict1 = BookOrderLineQuantityConflict.CreateExisting(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), 1, true, DateTime.UtcNow); var bookOrderLineConflict2 = BookOrderLinePriceConflict.CreateExisting(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), 30.25M, false, DateTime.UtcNow); sut.Store(new BookOrderLineConflict[] { bookOrderLineConflict1, bookOrderLineConflict2 }); var result = sut.Get(); var storedConflict1 = result.Single(x => x.Id == bookOrderLineConflict1.Id); storedConflict1.BookOrderId.Should().Be(bookOrderLineConflict1.BookOrderId); storedConflict1.ConflictType.Should().Be(bookOrderLineConflict1.ConflictType); storedConflict1.BookOrderLineId.Should().Be(bookOrderLineConflict1.BookOrderLineId); storedConflict1.ConflictValue.Should().Be(bookOrderLineConflict1.ConflictValue); storedConflict1.Accepted.Should().Be(bookOrderLineConflict1.Accepted); var storedConflict2 = result.Single(x => x.Id == bookOrderLineConflict2.Id); storedConflict2.BookOrderId.Should().Be(bookOrderLineConflict2.BookOrderId); storedConflict2.ConflictType.Should().Be(bookOrderLineConflict2.ConflictType); storedConflict2.BookOrderLineId.Should().Be(bookOrderLineConflict2.BookOrderLineId); storedConflict2.ConflictValue.Should().Be(bookOrderLineConflict2.ConflictValue); storedConflict2.Accepted.Should().Be(bookOrderLineConflict2.Accepted); }
private List <BookOrderLineConflict> CalculateOrderLineConflicts(BookOrder bookOrder, SupplierBookOrderUpdateRequest supplierBookOrderUpdateRequest) { List <BookOrderLineConflict> conflicts = new List <BookOrderLineConflict>(); var lineUpdates = supplierBookOrderUpdateRequest.OrderLineUpdates; foreach (var lineUpdate in lineUpdates) { var bookOrderLine = bookOrder.OrderLines.First(x => x.Id == lineUpdate.BookOrderLineId); if (bookOrderLine.Price != lineUpdate.Price) { conflicts.Add(BookOrderLinePriceConflict.CreateNew(bookOrder.Id, bookOrderLine.Id, lineUpdate.Price)); } if (bookOrderLine.Quantity != lineUpdate.Quantity) { conflicts.Add(BookOrderLineQuantityConflict.CreateNew(bookOrder.Id, bookOrderLine.Id, lineUpdate.Quantity)); } } return(conflicts); }
private static BookOrderLineConflict CreateConflict(string conflictType) { if (conflictType.Equals("Quantity")) { return(BookOrderLineQuantityConflict.CreateNew(Guid.NewGuid(), Guid.NewGuid(), 1)); } if (conflictType.Equals("Price")) { return(BookOrderLinePriceConflict.CreateNew(Guid.NewGuid(), Guid.NewGuid(), 10.5M)); } throw new ArgumentOutOfRangeException(); }
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(); }