public static WMUserSets Get(string id) { WMUserSets userSet = null; if (!General.IsNullable(id)) { DateTime now = DateTime.Now; using (WMContext context = new WMContext()) { userSet = ( from us in context.UserSets join g in context.Goods on us.GoodId equals g.Id join t in context.Options on us.TypeId equals t.Id where us.Id.Equals(id) select new WMUserSets { Id = us.Id, TypeId = us.TypeId, TypeName = t.Name, UserId = us.UserId, GoodId = us.GoodId, GoodName = g.Name, GoodFigure = context.GoodImages.Where(gi => gi.GoodId.Equals(us.GoodId) && gi.IsCover).Select(gi => gi.URL).FirstOrDefault(), AddDate = us.AddDate } ).FirstOrDefault(); } } return(userSet); }
public void Test_Fav_Add_Get() { WMUsers userToAdd = new WMUsers(); userToAdd.Id = General.UniqueString(userToAdd.Id); userToAdd.RoleId = 101; userToAdd.UserName = "******"; userToAdd.Password = "******"; userToAdd.NickName = "nick"; userToAdd.Mobile = "13512341234"; Assert.IsTrue(userToAdd.Add()); //添加category WMGoodCategories cateToAdd = new WMGoodCategories(); cateToAdd.ParentId = "root"; cateToAdd.Name = "珠宝"; bool isCateAdded = cateToAdd.Add(); Assert.IsTrue(isCateAdded); //添加good WMGoods goodToAdd = new WMGoods(); goodToAdd.CategoryId = cateToAdd.Id; goodToAdd.Name = "砖石项链"; goodToAdd.Unit = "件"; goodToAdd.OriginalPrice = 10000; goodToAdd.StatusId = 501; bool isGoodAdded = goodToAdd.Add(); Assert.IsTrue(isGoodAdded); WMUserSets userSet = new WMUserSets() { TypeId = 401, UserId = userToAdd.Id, GoodId = goodToAdd.Id, }; Assert.IsTrue(userSet.Add()); int pageCount; List<WMUserSets> favs = WMUserSets.GetList(out pageCount, 401, userToAdd.Id); Assert.AreEqual(1, favs.Count); Assert.AreEqual("砖石项链", favs[0].GoodName); }
public void Test_AddAllDatas() { bool isAdded = false; //express WMOrderExpress express = new WMOrderExpress() { Name = "顺丰", URL = "www.shufen.com" }; Assert.IsTrue(express.Add()); //Admins WMAdministrators adminToAdd = new WMAdministrators(); adminToAdd.RoleId = 302; adminToAdd.UserName = "******"; adminToAdd.Password = "******"; adminToAdd.Add(); //Users WMUsers userToAdd = new WMUsers(); userToAdd.Id = General.UniqueString(userToAdd.Id); userToAdd.RoleId = 101; userToAdd.UserName = "******"; userToAdd.Password = "******"; userToAdd.NickName = "nick"; userToAdd.Mobile = "13512341234"; Assert.IsTrue(userToAdd.Add()); //Categories //珠宝 WMGoodCategories cate_0 = new WMGoodCategories(); cate_0.ParentId = "root"; cate_0.Name = "珠宝"; isAdded = cate_0.Add(); Assert.IsTrue(isAdded); WMGoodCategories cate_0_0 = new WMGoodCategories(); cate_0_0.ParentId = cate_0.Id; cate_0_0.Name = "项链"; isAdded = cate_0_0.Add(); Assert.IsTrue(isAdded); WMGoodCategories cate_0_1 = new WMGoodCategories(); cate_0_1.ParentId = cate_0.Id; cate_0_1.Name = "手镯"; isAdded = cate_0_1.Add(); Assert.IsTrue(isAdded); //服装 WMGoodCategories cate_1 = new WMGoodCategories(); cate_1.ParentId = "root"; cate_1.Name = "服装"; isAdded = cate_1.Add(); Assert.IsTrue(isAdded); WMGoodCategories cate_1_0 = new WMGoodCategories(); cate_1_0.ParentId = cate_1.Id; cate_1_0.Name = "衬衫"; isAdded = cate_1_0.Add(); Assert.IsTrue(isAdded); WMGoodCategories cate_1_1 = new WMGoodCategories(); cate_1_1.ParentId = cate_1.Id; cate_1_1.Name = "T恤"; isAdded = cate_1_1.Add(); Assert.IsTrue(isAdded); //添加good WMGoods goodToAdd = new WMGoods(); goodToAdd.CategoryId = cate_0.Id; goodToAdd.Name = "砖石项链"; goodToAdd.Unit = "件"; goodToAdd.OriginalPrice = 10000; goodToAdd.StatusId = 501; bool isGoodAdded = goodToAdd.Add(); Assert.IsTrue(isGoodAdded); WMGoods good2ToAdd = new WMGoods(); good2ToAdd.CategoryId = cate_0_0.Id; good2ToAdd.Name = "黄金项链"; good2ToAdd.Unit = "件"; good2ToAdd.OriginalPrice = 10000; good2ToAdd.StatusId = 501; good2ToAdd.Add(); WMGoods good3ToAdd = new WMGoods(); good3ToAdd.CategoryId = cate_0_0.Id; good3ToAdd.Name = "红宝石项链"; good3ToAdd.Unit = "件"; good3ToAdd.OriginalPrice = 10000; good3ToAdd.StatusId = 501; good3ToAdd.Add(); WMGoods good4ToAdd = new WMGoods(); good4ToAdd.CategoryId = cate_0_0.Id; good4ToAdd.Name = "蓝宝石项链"; good4ToAdd.Unit = "件"; good4ToAdd.OriginalPrice = 10000; good4ToAdd.StatusId = 501; good4ToAdd.Add(); WMGoods good5ToAdd = new WMGoods(); good5ToAdd.CategoryId = cate_0_0.Id; good5ToAdd.Name = "绿宝石项链"; good5ToAdd.Unit = "件"; good5ToAdd.OriginalPrice = 10000; good5ToAdd.StatusId = 501; good5ToAdd.Add(); WMGoods good6ToAdd = new WMGoods(); good6ToAdd.CategoryId = cate_0_0.Id; good6ToAdd.Name = "黄宝石项链"; good6ToAdd.Unit = "件"; good6ToAdd.OriginalPrice = 10000; good6ToAdd.StatusId = 501; good6ToAdd.Add(); WMGoods good7ToAdd = new WMGoods(); good7ToAdd.CategoryId = cate_0_0.Id; good7ToAdd.Name = "珍珠项链"; good7ToAdd.Unit = "件"; good7ToAdd.OriginalPrice = 10000; good7ToAdd.StatusId = 501; good7ToAdd.Add(); WMGoods good8ToAdd = new WMGoods(); good8ToAdd.CategoryId = cate_0_0.Id; good8ToAdd.Name = "石头项链"; good8ToAdd.Unit = "件"; good8ToAdd.OriginalPrice = 10000; good8ToAdd.StatusId = 501; good8ToAdd.Add(); WMGoods good9ToAdd = new WMGoods(); good9ToAdd.CategoryId = cate_0_0.Id; good9ToAdd.Name = "水泥项链"; good9ToAdd.Unit = "件"; good9ToAdd.OriginalPrice = 10000; good9ToAdd.StatusId = 501; good9ToAdd.Add(); WMGoods good10ToAdd = new WMGoods(); good10ToAdd.CategoryId = cate_0_0.Id; good10ToAdd.Name = "1项链"; good10ToAdd.Unit = "件"; good10ToAdd.OriginalPrice = 10000; good10ToAdd.StatusId = 501; good10ToAdd.Add(); WMGoods good11ToAdd = new WMGoods(); good11ToAdd.CategoryId = cate_0_0.Id; good11ToAdd.Name = "2项链"; good11ToAdd.Unit = "件"; good11ToAdd.OriginalPrice = 10000; good11ToAdd.StatusId = 501; good11ToAdd.Add(); WMGoods good12ToAdd = new WMGoods(); good12ToAdd.CategoryId = cate_0_0.Id; good12ToAdd.Name = "3项链"; good12ToAdd.Unit = "件"; good12ToAdd.OriginalPrice = 10000; good12ToAdd.StatusId = 501; good12ToAdd.Add(); WMGoods good13ToAdd = new WMGoods(); good13ToAdd.CategoryId = cate_0_0.Id; good13ToAdd.Name = "4项链"; good13ToAdd.Unit = "件"; good13ToAdd.OriginalPrice = 10000; good13ToAdd.StatusId = 501; good13ToAdd.Add(); WMGoods good14ToAdd = new WMGoods(); good14ToAdd.CategoryId = cate_0_0.Id; good14ToAdd.Name = "5项链"; good14ToAdd.Unit = "件"; good14ToAdd.OriginalPrice = 10000; good14ToAdd.StatusId = 501; good14ToAdd.Add(); WMGoods good15ToAdd = new WMGoods(); good15ToAdd.CategoryId = cate_0_0.Id; good15ToAdd.Name = "6项链"; good15ToAdd.Unit = "件"; good15ToAdd.OriginalPrice = 10000; good15ToAdd.StatusId = 501; good15ToAdd.Add(); WMGoods good16ToAdd = new WMGoods(); good16ToAdd.CategoryId = cate_0_0.Id; good16ToAdd.Name = "7项链"; good16ToAdd.Unit = "件"; good16ToAdd.OriginalPrice = 10000; good16ToAdd.StatusId = 501; good16ToAdd.Add(); WMGoods good17ToAdd = new WMGoods(); good17ToAdd.CategoryId = cate_0_0.Id; good17ToAdd.Name = "8项链"; good17ToAdd.Unit = "件"; good17ToAdd.OriginalPrice = 10000; good17ToAdd.StatusId = 501; good17ToAdd.Add(); //添加brand WMGoodBrands brand1 = new WMGoodBrands(); brand1.Name = "卡地亚"; Assert.IsTrue(brand1.Add()); WMGoodBrands brand2 = new WMGoodBrands(); brand2.Name = "爱马仕"; Assert.IsTrue(brand2.Add()); //Car WMShopCars car = new WMShopCars() { GoodId = goodToAdd.Id, UserId = userToAdd.Id, Price = 100, Count = 2, }; Assert.IsTrue(car.Add()); WMShopCars car2 = new WMShopCars() { GoodId = good2ToAdd.Id, UserId = userToAdd.Id, Price = 500, Count = 3, }; Assert.IsTrue(car2.Add()); WMOrders order = new WMOrders() { UserId = userToAdd.Id, Address = "上海哪儿哪儿哪儿", Contact = "小李", Phone = "13512341235", ZipCode = "240101", ProvinceId = 110000, CityId = 110100, AreaId = 110101, PayId = 621, ExpressId = express.Id }; Assert.IsTrue(order.Add()); WMOrderGoods orderGood = new WMOrderGoods() { Count = 2, GoodId = goodToAdd.Id, OrderId = order.Id, Price = 100, }; Assert.IsTrue(orderGood.Add()); //Add address WMUserReceipts receipt = new WMUserReceipts() { UserId = userToAdd.Id, Address = "上海哪儿哪儿哪儿", Contact = "小李", Phone = "13512341235", ZipCode = "240101", ProvinceId = 110000, CityId = 110100, AreaId = 110101, }; Assert.IsTrue(receipt.Add()); //用户收藏 WMUserSets userSet = new WMUserSets() { TypeId = 401, UserId = userToAdd.Id, GoodId = goodToAdd.Id, }; Assert.IsTrue(userSet.Add()); //用户积分 WMUserIntegrals intergral = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral.Add()); WMUserIntegrals intergral2 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral2.Add()); WMUserIntegrals intergral3 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral3.Add()); WMUserIntegrals intergral4 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral4.Add()); WMUserIntegrals intergral5 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral5.Add()); WMUserIntegrals intergral6 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral6.Add()); WMUserIntegrals intergral7 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral7.Add()); WMUserIntegrals intergral8 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral8.Add()); //用户返利 WMUserBonus bonus = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 101, }; Assert.IsTrue(bonus.Add()); WMUserBonus bonus2 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus2.Add()); WMUserBonus bonus3 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus3.Add()); WMUserBonus bonus4 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus4.Add()); WMUserBonus bonus5 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus5.Add()); WMUserBonus bonus6 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus6.Add()); }