Exemple #1
0
 public OrderShippingConfirmation SendRequestForDelivery(Order order)
 {
     var randomDelay = new Random().Next(10); 
     var trackId = new Random().Next(10000000);
     return new OrderShippingConfirmation()
     {
         ExpectedShipDate = DateTime.Today.AddDays(randomDelay),
         TrackingId = trackId.ToString()
     };
 }
Exemple #2
0
 public static Order CreateFromShoppingCart(int temporaryId, ShoppingCart cart)
 {
     var order = new Order(temporaryId, cart.Buyer);
     foreach (var cartItem in cart.Items)
     {
         var orderItem = OrderItem.CreateNewForOrder(order, cartItem.Quantity, cartItem.Product);
         order.Items.Add(orderItem);
         order.Total = cart.GetTotal();
     }
     return order;
 }
Exemple #3
0
 public int AddAndReturnKey(Order aggregate)
 {
     using (var db = new CommandModelDatabase())
     {
         db.Entry(aggregate.Buyer).State = EntityState.Unchanged;
         db.Orders.Add(aggregate);
         if (db.SaveChanges() > 0)
         {
             return aggregate.OrderId;
         }
         return 0;
     }
 }
        public static OrderFoundViewModel CreateFromOrder(Order order)
        {
            if (order == null)
                return new OrderFoundViewModel();

            var model = new OrderFoundViewModel()
            {
                Id = order.OrderId,
                State = order.State,
                OrderDate = order.Date,
                Total = order.Total.ToString()
            };
            foreach (var item in order.Items)
            {
                model.Details.Add(item);
            }
            return model;
        }
Exemple #5
0
 // The class has no public constructor because instances of it will only be 
 // created materializing from storage. An O/RM will do it and it can use
 // the protected ctor.
 public static Order CreateNew(int id, Customer customer)
 {
     var order = new Order(id, customer);
     return order;
 }
Exemple #6
0
 public static OrderItem CreateNewForOrder(Order order, int quantity, Product product)
 {
     var item = new OrderItem { Quantity = quantity, Product = product, Order = order };
     return item;
 }
Exemple #7
0
 public bool Delete(Order aggregate)
 {
     throw new NotImplementedException();
 }