Exemplo n.º 1
0
        public static Order GetOrderFromDto(OrderDto order)
        {
            if (order == null) return null;

            Order o = new Order()
            {
                OrderID = order.OrderId,
                Latitude = order.Latitude,
                Longitude = order.Longitude,
                SubmittedAt = order.SubmittedAt,
                DeliveredAt = order.DeliveredAt,
                Status = !order.Status.HasValue ? eOrderStatus.NEW : (eOrderStatus)eOrderStatus.Parse(typeof(eOrderStatus),order.Status.ToString(),true),
                OrderedProducts = new List<ProductOrder>()
            };
            foreach (var product in order.Products)
            {
                o.OrderedProducts.Add(new ProductOrder()
                    {
                        OriginOrder = o,
                        Units = product.Units,
                        ProductID = product.ProductID
                    });
            }
            return o;
        }
Exemplo n.º 2
0
        public int StoreOrder(Order order)
        {
            DataStore.StoreOrder(order);
            Cache.Add(order.OrderID, order);

            return order.OrderID;
        }
Exemplo n.º 3
0
        public static OrderDto OrderDtoFromOrderModel(Order order)
        {
            if (order == null) return null;

            OrderDto dto = new OrderDto()
            {
                OrderId = order.OrderID,
                Latitude = order.Latitude,
                Longitude = order.Longitude,
                SubmittedAt = order.SubmittedAt,
                DeliveredAt = order.DeliveredAt,
                Status = (OrderStatus)OrderStatus.Parse(typeof(OrderStatus),order.Status.ToString(),true),
                Products = new List<ProductOrderDto>()
            };
            foreach (var product in order.OrderedProducts)
            {
                dto.Products.Add(new ProductOrderDto()
                    {
                        ProductID = product.ProductID,
                        Units = product.Units
                    });
            }
            return dto;
        }
Exemplo n.º 4
0
 public int StoreOrder(Order order)
 {
     order.OrderID = random.Next(0, 10000);
     Cache.Add(order.OrderID, order);
     return order.OrderID;
 }
Exemplo n.º 5
0
        public int StoreOrder(Order order)
        {
            using (MySqlOrdersDb Db = new MySqlOrdersDb(ConnectionString))
            {
                Db.Orders.Add(order);
                Db.SaveChanges();
            }

            return order.OrderID;
        }
Exemplo n.º 6
0
 public void BaseSetUp()
 {
     newOrder = OrderTest.GetNewOrder();
     completedOrder = OrderTest.GetDeliveredOrder();
     canceledOrder = OrderTest.GetCancelledOrder();
 }
Exemplo n.º 7
0
        public int StoreOrder(Order order)
        {
            var orders = AllOrders();
            order.OrderID = DateTime.Now.Millisecond;
            orders.Add(order);
            using(FileStream stream = File.Open(FilePath,FileMode.Create))
            {
                Serializer.Serialize(stream, orders);
            }

            return order.OrderID;
        }