//发布订单16 ok
        public List<Order> PublishOrder(List<Commodity> commodityList, String userFrom)
        {
            List<Order> OrderList = new List<Order>();
            Dictionary<String,int> SellerNameAndOderIDList = new Dictionary<string,int>();

            //把商品按商家归类
            foreach (Commodity commodity in commodityList)
            {
                if (!SellerNameAndOderIDList.Keys.Contains(commodity.UserName))
                {
                    SellerNameAndOderIDList.Add(commodity.UserName,0);
                }
            }

            //数据访存器
            DatabaseAccess.DataClasses1DataContext DBAccessor = new DataClasses1DataContext();

            //以卖家为单位插入订单,并返回订单号
            foreach (String Seller in SellerNameAndOderIDList.Keys)
            {
                try
                {
                    int OderID = DBAccessor.insertOrder(userFrom,Seller);
                    SellerNameAndOderIDList[Seller] = OderID;
                }
                catch (Exception e)
                {

                }
            }

            //以订单号为单位插入商品
            foreach (String SellerName in SellerNameAndOderIDList.Keys)
            {
                //订单
                Order order = new Order();
                try
                {
                    foreach (Commodity commodity in commodityList)
                    {
                        if (commodity.UserName == SellerName)
                        {
                            DBAccessor.insertOrderCommodity(SellerNameAndOderIDList[SellerName], commodity.ID);
                            order.userTo.UserName = SellerName;
                            order.commodityList.Add(commodity);//加入订单的商品列表中
                            order.ID = SellerNameAndOderIDList[SellerName];//订单号
                        }
                    }
                }
                catch (Exception e)
                {

                }
                OrderList.Add(order);
            }
            return OrderList;
        }
        //获得发向用户的订单8 ok
        public List<Order> GetOreders(String UserID)
        {
            List<Order> OrderList = new List<Order>();
            //数据访存器
            DatabaseAccess.DataClasses1DataContext DBAccessor = new DataClasses1DataContext();

            try
            {
                ISingleResult<getOrderByUsertoResult> resultList = DBAccessor.getOrderByUserto(UserID);
                foreach (getOrderByUsertoResult result in resultList)
                {
                    Order order = new Order();
                    order.ID = result.id;
                    order.userTo.UserName = result.userto;

                    //下面获得发订单的用户
                    order.userFrom.UserName = result.userfrom;
                    //发订单用户的信息
                    ISingleResult<getUserByUserNameResult> UserInfoList = DBAccessor.getUserByUserName(result.userfrom);
                    foreach (getUserByUserNameResult UserInfo in UserInfoList)
                    {
                        order.userFrom.NickName = UserInfo.nickname;
                        order.userFrom.Phone = UserInfo.phone;
                        order.userFrom.Address = UserInfo.address;
                        order.userFrom.Email = UserInfo.email;
                        order.userFrom.City = UserInfo.city;
                        order.userFrom.Portrait = UserInfo.portraitPath;
                    }

                    //查找次订单所对应的所有商品
                    ISingleResult<getCommodityByOrederResult> commmodityListresult = DBAccessor.getCommodityByOreder(result.id);
                    //获得订单所对应的商品列表
                    foreach (getCommodityByOrederResult commmodityResult in commmodityListresult)
                    {
                        Commodity commodity = new Commodity();
                        commodity.ID = commmodityResult.id;
                        commodity.Name = commmodityResult.name;
                        commodity.UserName = commmodityResult.userfrom;
                        commodity.kind = (CommodityKind)(int)commodity.kind;
                        commodity.StartTime = (DateTime)commmodityResult.starttime;
                        commodity.EndTime = (DateTime)commmodityResult.endtime;
                        commodity.description = commmodityResult.discription;
                        commodity.ImageUrl = commmodityResult.picturepath;
                        commodity.Price = (int)commmodityResult.price;

                        //获得商品的tag列表
                        ISingleResult<getTagByCommodityResult> tagResultList = DBAccessor.getTagByCommodity(commmodityResult.id);
                        foreach (getTagByCommodityResult tagResult in tagResultList)
                        {
                            Tag tag = new Tag();
                            tag.name = tagResult.id;
                            tag.popularity = (int)tagResult.popularity;
                            //加入商品的Tag列表
                            commodity.tagList.Add(tag);
                        }
                        //把商品加入订单的商品列表
                        order.commodityList.Add(commodity);
                    }

                    //订单加入订单列表
                    OrderList.Add(order);
                }
            }
            catch (Exception e)
            {

            }
            return OrderList;
        }