Пример #1
0
        public BusinessModel.OrderDetail GetOrderDetailById(Guid orderId)
        {
            BusinessModel.OrderDetail detail = null;

            OrderDal orderDal = new OrderDal();

            var orderSummary = orderDal.GetOrderSummary(orderId);

            if (orderSummary != null)
            {
                detail = new BusinessModel.OrderDetail();

                detail.OrderId = orderSummary.OrderId;
                detail.ContactName = orderSummary.ContactName;
                detail.Telephone = orderSummary.ContactPhone;
                detail.DiningDate = orderSummary.DiningDate;
                detail.CreateTime = orderSummary.CreateTime;
                detail.Backlog = orderSummary.Backlog;
                detail.PersonCount = orderSummary.PersonCount;
                detail.Status = orderSummary.Status;
                detail.TotalMoney = orderSummary.TotalMoney;

                var details = orderDal.GetOrderDetails(orderId);

                if (details != null)
                {
                    if (detail.TotalMoney == 0)
                    {
                        detail.TotalMoney = details.First().TotalPrice;
                    }
                    var productIds = details.Select(v => v.ProductId).ToList();
                    var products = orderDal.GetProducts(productIds);

                    if (products != null && products.Count > 0)
                    {
                        detail.ProductList = new List<BusinessModel.Product>();

                        foreach (var subDetail in details)
                        {
                            var productDetail = products.FirstOrDefault(v => v.ProductId == subDetail.ProductId);
                            if (productDetail != null)
                            {
                                var product = new BusinessModel.Product();

                                product.ProductId = subDetail.ProductId;
                                product.UnitPrice = subDetail.UnitPrice;
                                product.Count = subDetail.ProductCount;

                                product.ProductName = productDetail.ProductName;
                                productDetail.Image = productDetail.Image;

                                detail.ProductList.Add(product);
                            }
                        }
                    }
                }
            }

            return detail;
        }
Пример #2
0
        public EntityModel.OrderSummary GetOrderSummary(Guid orderId)
        {
            EntityModel.OrderSummary summary = null;

            OrderDal orderDal = new OrderDal();
            summary = orderDal.GetOrderSummary(orderId);

            return summary;
        }
Пример #3
0
        public List<BusinessModel.OrderSummary> GetUserOrders(string memberCardNo)
        {
            List<BusinessModel.OrderSummary> list = null;

            OrderDal orderDal = new OrderDal();

            var entities = orderDal.GetUserOrders(memberCardNo);
            if (entities != null && entities.Count > 0)
            {
                list = entities.Select(v => new BusinessModel.OrderSummary
                {
                    OrderId = v.OrderId,
                    RestaurantId = v.RestaurantId,
                    RestaurantName = v.RestaurantName,
                    ContactName = v.ContactName,
                    ContactPhone = v.ContactPhone,
                    TotalMoney = v.TotalMoney,
                    Status = v.Status,
                    DiningDate = v.DiningDate,
                    CreateTime = v.CreateTime,
                    Backlog = v.Backlog,
                    PersonCount = v.PersonCount
                }).ToList();
            }

            return list;
        }