コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }