//获得发向用户的订单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; }