Exemplo n.º 1
0
        private void AddNoteToOrder(IOrderGroup order, string noteDetails, OrderNoteTypes type, Guid customerId)
        {
            if (order == null)
            {
                throw new ArgumentNullException("purchaseOrder");
            }
            var orderNote = order.CreateOrderNote();

            if (!orderNote.OrderNoteId.HasValue)
            {
                var newOrderNoteId = -1;

                if (order.Notes.Count != 0)
                {
                    newOrderNoteId = Math.Min(order.Notes.ToList().Min(n => n.OrderNoteId.Value), 0) - 1;
                }

                orderNote.OrderNoteId = newOrderNoteId;
            }

            orderNote.CustomerId = customerId;
            orderNote.Type       = type.ToString();
            orderNote.Title      = noteDetails.Substring(0, Math.Min(noteDetails.Length, 24)) + "...";
            orderNote.Detail     = noteDetails;
            orderNote.Created    = DateTime.UtcNow;
        }
Exemplo n.º 2
0
 private static void AddCartNotesToPurchaseOrder(IOrderGroup purchaseOrder, ICart cart)
 {
     foreach (var cartNote in cart.Notes)
     {
         var poNote = purchaseOrder.CreateOrderNote();
         poNote.Title      = cartNote.Title;
         poNote.Detail     = $"{cartNote.Created} {cartNote.Title}: {cartNote.Detail}";
         poNote.Type       = cartNote.Type;
         poNote.CustomerId = cartNote.CustomerId;
         poNote.LineItemId = cartNote.LineItemId;
         purchaseOrder.Notes.Add(poNote);
     }
 }