public void Handle(IOrderAcceptedEvent message) { MusicStoreEntities storeDB = new MusicStoreEntities(); var order = storeDB.Orders.Single(o => o.OrderId == message.OrderId); var shipNote = new ShippingNote { FirstName = order.FirstName, LastName = order.LastName, Address = order.Address, City = order.City, State = order.State, PostalCode = order.PostalCode }; foreach (var detail in order.OrderDetails) { var inventoryPosition = storeDB.InventoryPositions.Single(p => p.Album.AlbumId == detail.AlbumId); if (inventoryPosition.BalanceOnHand >= detail.Quantity) { inventoryPosition.BalanceOnHand -= detail.Quantity; shipNote.ShippedQuantity += detail.Quantity; } else { shipNote.BackOrderQuantity = detail.Quantity - shipNote.ShippedQuantity; } } storeDB.AddToShippingNotes(shipNote); storeDB.SaveChanges(); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is OrderFulfillmentShipmentDetails other && ((Recipient == null && other.Recipient == null) || (Recipient?.Equals(other.Recipient) == true)) && ((Carrier == null && other.Carrier == null) || (Carrier?.Equals(other.Carrier) == true)) && ((ShippingNote == null && other.ShippingNote == null) || (ShippingNote?.Equals(other.ShippingNote) == true)) && ((ShippingType == null && other.ShippingType == null) || (ShippingType?.Equals(other.ShippingType) == true)) && ((TrackingNumber == null && other.TrackingNumber == null) || (TrackingNumber?.Equals(other.TrackingNumber) == true)) && ((TrackingUrl == null && other.TrackingUrl == null) || (TrackingUrl?.Equals(other.TrackingUrl) == true)) && ((PlacedAt == null && other.PlacedAt == null) || (PlacedAt?.Equals(other.PlacedAt) == true)) && ((InProgressAt == null && other.InProgressAt == null) || (InProgressAt?.Equals(other.InProgressAt) == true)) && ((PackagedAt == null && other.PackagedAt == null) || (PackagedAt?.Equals(other.PackagedAt) == true)) && ((ExpectedShippedAt == null && other.ExpectedShippedAt == null) || (ExpectedShippedAt?.Equals(other.ExpectedShippedAt) == true)) && ((ShippedAt == null && other.ShippedAt == null) || (ShippedAt?.Equals(other.ShippedAt) == true)) && ((CanceledAt == null && other.CanceledAt == null) || (CanceledAt?.Equals(other.CanceledAt) == true)) && ((CancelReason == null && other.CancelReason == null) || (CancelReason?.Equals(other.CancelReason) == true)) && ((FailedAt == null && other.FailedAt == null) || (FailedAt?.Equals(other.FailedAt) == true)) && ((FailureReason == null && other.FailureReason == null) || (FailureReason?.Equals(other.FailureReason) == true))); }
public static CsvShippingNoteLine ToCsvLine(this ShippingNote shipping) { if (shipping == null) { throw new ArgumentNullException(nameof(shipping)); } return(new CsvShippingNoteLine() { CustomerId = shipping.Order.CustomerId, Name = shipping.Order.Name, Shipper = shipping.Shipper, Duration = shipping.Duration, ShippingCost = shipping.ShippingCost }); }
public override int GetHashCode() { int hashCode = 1108362053; if (Recipient != null) { hashCode += Recipient.GetHashCode(); } if (Carrier != null) { hashCode += Carrier.GetHashCode(); } if (ShippingNote != null) { hashCode += ShippingNote.GetHashCode(); } if (ShippingType != null) { hashCode += ShippingType.GetHashCode(); } if (TrackingNumber != null) { hashCode += TrackingNumber.GetHashCode(); } if (TrackingUrl != null) { hashCode += TrackingUrl.GetHashCode(); } if (PlacedAt != null) { hashCode += PlacedAt.GetHashCode(); } if (InProgressAt != null) { hashCode += InProgressAt.GetHashCode(); } if (PackagedAt != null) { hashCode += PackagedAt.GetHashCode(); } if (ExpectedShippedAt != null) { hashCode += ExpectedShippedAt.GetHashCode(); } if (ShippedAt != null) { hashCode += ShippedAt.GetHashCode(); } if (CanceledAt != null) { hashCode += CanceledAt.GetHashCode(); } if (CancelReason != null) { hashCode += CancelReason.GetHashCode(); } if (FailedAt != null) { hashCode += FailedAt.GetHashCode(); } if (FailureReason != null) { hashCode += FailureReason.GetHashCode(); } return(hashCode); }