Exemple #1
0
        public void CreateOrder(Order order)
        {
            if (order == null)
            {
                throw new ArgumentNullException("order");
            }
            if (!order.Lines.Any())
            {
                throw new ArgumentException("order.Lines");
            }

            order.OrderId     = NewOrderId();
            order.Status      = "newcreated";
            order.CreatedTime = DateTime.Now;

            DatabaseFactory.CreateDatabase("mall").ExecuteTransaction(db => {
                var orderRepo = new OrderRepo(db);
                orderRepo.Save(order);

                var orderLineRepo = new OrderLineRepo(db);
                foreach (var orderLine in order.Lines)
                {
                    orderLineRepo.Save(order.OrderId, orderLine);
                }
            });
        }
Exemple #2
0
        public Order GetWithLinesByOrderId(string orderId)
        {
            var sql = @"select * from [Order] where OrderId = @orderId";
            return _Database.ExecuteDataReader(sql, new {orderId}, dr => {
                var order = Order.GetByDataReader(dr);

                var orderLineRepo = new OrderLineRepo(_Database);
                order.Lines = orderLineRepo.GetByOrderId(order.OrderId);

                return order;
            }).FirstOrDefault();
        }
Exemple #3
0
        public Order GetWithLinesByOrderId(string orderId)
        {
            var sql = @"select * from [Order] where OrderId = @orderId";

            return(_Database.ExecuteDataReader(sql, new { orderId }, dr => {
                var order = Order.GetByDataReader(dr);

                var orderLineRepo = new OrderLineRepo(_Database);
                order.Lines = orderLineRepo.GetByOrderId(order.OrderId);

                return order;
            }).FirstOrDefault());
        }
        public void CreateOrder(Order order)
        {
            if (order == null)
                throw new ArgumentNullException("order");
            if (!order.Lines.Any())
                throw new ArgumentException("order.Lines");

            order.OrderId = NewOrderId();
            order.Status = "newcreated";
            order.CreatedTime = DateTime.Now;

            DatabaseFactory.CreateDatabase("mall").ExecuteTransaction(db => {
                var orderRepo = new OrderRepo(db);
                orderRepo.Save(order);

                var orderLineRepo = new OrderLineRepo(db);
                foreach (var orderLine in order.Lines)
                    orderLineRepo.Save(order.OrderId, orderLine);
            });
        }