static async Task Main() { var stopwatch = new Stopwatch(); stopwatch.Start(); using var shopService = new ShopService("*****@*****.**", "PRland1234"); var shop = (await shopService.GetProductsAsync("https://www.facebook.com/pg/Shop-and-Go-105766151037772")); var shopProducts = shop.Data; stopwatch.Stop(); var stopwatchElapsed = stopwatch.Elapsed; Console.WriteLine("\tProducts\t\n ---------------------------\n "); foreach (var variable in shopProducts) { Console.WriteLine($"Name: {variable.Name}\nPrice: {variable.Price?.Cost}{variable.Price?.Currency}\nTotal: {variable.Price?.Total }\nDescription: {variable.Description}\nImage: {variable.ImagesUrl}\n"); } Console.ReadKey(); }
void ShowPanel() { string sln = SiteConfigs.GetConfig().ShopLoginName; if (String.IsNullOrEmpty(sln) || String.IsNullOrEmpty(sln.Trim())) { Messages.ShowMessage("本站尚未登记We7插件商店帐号!只有登记了We7插件商店帐号,才能在本地站点看到已购买的We7插件。"); ShowRegistePanl(true); } else { try { SiteConfigInfo si = SiteConfigs.GetConfig(); string[] states = ShopService.CheckSite(si.ShopLoginName, si.ShopPassword, si.SiteUrl); if (states != null && states.Length > 0 && states[0] == "1") { ShowRegistePanl(false); } else { Messages.ShowMessage("本站使用的的插件商店帐号有误!请重新登记插件商店帐号!"); ShowRegistePanl(true); } } catch (Exception ex) { Messages.ShowError("应用程序错误!错误原因:" + ex.Message); plList.Visible = false; plSN.Visible = false; } } }
public void CanObserveConsistentGameStateChanges() { var gameStateService = GameStateService.Get(); gameStateService.Init(10, 0); var gameState = gameStateService.State; var stateObserverCalled = false; void StateValidator() { stateObserverCalled = true; Assert.That(gameState.Stars, Is.EqualTo(1)); Assert.That(gameState.Coins, Is.EqualTo(9)); } gameState.AddOnCoinsChanged(StateValidator); gameState.AddOnStarsChanged(StateValidator); var shopService = ShopService.Get(); shopService.BuyStars(1, 1); gameState.Observer.ExecuteActions(); Assert.That(stateObserverCalled, "Observer not called"); }
// GET: Shop public ActionResult Index() { var service = new ShopService(); var model = service.GetShops(); return(View(model)); }
public void Setup() { var items = new List <InventoryItem>() { new InventoryItem("testuser", "testitem") { InventoryPosition = 4, Item = new Consumable() { Price = 1337 * 2 } }, new InventoryItem("testuser", "testitem") { InventoryPosition = 3, Item = new EquipmentItem() } }; _user = new User() { Id = "testuser", InventoryItems = items }; _userRepository.Setup(repo => repo.GetUser(User)).Returns(_user); _shopService = new ShopService(_inventoryRepository.Object, _itemRepository.Object, _governmentService.Object, _creditsRepository.Object); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string nick = ""; if (Request.Cookies["nick"] != null) { nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); //"nick"; } else { nick = Session["snick"].ToString(); } if (nick == "") { Response.Write("请重新登录"); return; } TaoBaoShopInfo info = new ShopService().SelectShopByNick(nick); ViewState["shopcid"] = "50023878"; if (info != null) { ViewState["shopcid"] = info.CateId; TB_ShppName.Text = info.Name; TB_Description.Value = info.Description; TB_AliWang.Text = nick; TB_ShowUrl.Text = "http://shop" + info.ShopId + ".taobao.com/"; ViewState["logourl"] = " http://logo.taobao.com/shop-logo" + info.ShopLogo; } } }
public void GetAllCategoriesShouldReturnCategories() { var options = new DbContextOptionsBuilder <IntillegioContext>() .UseInMemoryDatabase(databaseName: "Get_All_Categories_Db") .Options; var dbContext = new IntillegioContext(options); var categoriesCount = 4; var compareCategories = new List <Category>(); for (int i = 0; i < categoriesCount; i++) { var category = new Category(); dbContext.Categories.Add(category); compareCategories.Add(category); } dbContext.SaveChanges(); var service = new ShopService(dbContext, null); var categories = service.GetAllCategories(); Assert.Equal(compareCategories, categories.Result); }
public void TestSellArticle_ShouldFailToSellArticle() { var shopService = new ShopService(); Article article = null; shopService.SellArticle(1, article, 10); }
static void Main(string[] args) { ShopService.SavePurchasesToXml("D:\\1.xml"); //Purchase p2 = new Purchase() //{ // Date = DateTime.Now, // UserId = 322, // PurchaseProducts = new PurchaseProduct[] { new PurchaseProduct { ProductId = 9, Quantity = 12 } } //}; //Purchase p1 = new Purchase { PurchaseId = 6 }; //ShopService.UpdatePurchase(p1, p2); //Product tmp = new Product { Name = "broiler",Price=0,Category=1 }; //Purchase p1 = new Purchase { Date = DateTime.Now, UserId = 22, // PurchaseProducts = new PurchaseProduct[] { new PurchaseProduct { ProductId = 10 } , new PurchaseProduct {ProductId = 2,Quantity=2 } } }; //ShopService.AddPurchase(p1); using (CodeFirstExistingDb.ShopModel dbc = new CodeFirstExistingDb.ShopModel()) { //DbFirst.Product temp = new DbFirst.Product() { Category = DbFirst.ProductCategory.groceries, ProductId = 3 }; //List<DbFirst.Product> a = dbc.Products.ToList<DbFirst.Product>(); //if (a.Contains(temp)) Console.WriteLine("yes"); //else Console.WriteLine("no"); foreach (var item in dbc.Purchases) { Console.WriteLine("Username with id " + item.UserId + " bought on " + "{0:d}" + " this goods:", item.Date.Value); foreach (var product in item.PurchaseProducts) { Console.WriteLine(product.Quantity.ToString() + " " + product.Product.Category + " pieces of " + product.Product.Name + ", total price:" + "{0:c}", product.Quantity * product.Product.Price); } Console.WriteLine(); } } Console.ReadKey(); }
private void SetItem(Account item) { this.SetInnerObject(item); if (item != null && item.OwnerId != null) { var owner = MembershipService.GetUserById(item.OwnerId.Value); DisplayName = owner.DisplayName; BirthDate = owner.BirthDate; Address = owner.Address; IdentityCard = owner.IdentityCard; Mobile.HasBinding = !string.IsNullOrWhiteSpace(HostSite.MessageTemplateOfIdentity); Mobile.Value1 = owner.Mobile; Mobile.Value2 = owner.Mobile2; Mobile.IsMobileAvailable = owner.IsMobileAvailable; PhoneNumber.Value1 = owner.PhoneNumber; PhoneNumber.Value2 = owner.PhoneNumber2; //Photo = new Picture("~/content/userphotos/{0}", owner.Photo, 120); this.Gender.Key = owner.Gender ?? 0; } var shop = ShopService.GetById(item.ShopId); if (shop != null) { ShopName = shop.DisplayName; } }
public void TestOrderArticle_ShouldReturnOrderdArticle() { var shopService = new ShopService(); var expected = new Article() { Id = 1, NameOfArticle = "Article from supplier3", ArticlePrice = 460 }; var article = shopService.OrderArticle(1, 520); Assert.AreEqual(expected.Id, article.Id); Assert.AreEqual(expected.NameOfArticle, article.NameOfArticle); Assert.AreEqual(expected.ArticlePrice, article.ArticlePrice); expected = new Article() { Id = 1, NameOfArticle = "Article from supplier1", ArticlePrice = 458 }; article = shopService.OrderArticle(1, 458); Assert.AreEqual(expected.Id, article.Id); Assert.AreEqual(expected.NameOfArticle, article.NameOfArticle); Assert.AreEqual(expected.ArticlePrice, article.ArticlePrice); }
public void CanObserveConsistentGameStateChanges() { var gameStateService = GameStateService.Get(); gameStateService.Init(10, 0); var stateObserverCalled = false; void StateValidator() { CanObserveConsistentGameStateChanges stateChanges = new CanObserveConsistentGameStateChanges(); stateObserverCalled = true; ObserverController.Get().observableProperity.Register(stateChanges); ObserverController.Get().observableProperity.Propriety = new List <int> { 1, 9 }; } gameStateService.State.CoinsChanged += StateValidator; gameStateService.State.StarsChanged += StateValidator; var shopService = ShopService.Get(); shopService.BuyStars(1, 1); ObserverController.Get().observableProperity.Notify(); Assert.That(stateObserverCalled, "Obsever not called"); }
private void XtraFrm门店出库_Load(object sender, EventArgs e) { this.searchLookUpEdit1.Properties.DataSource = ShopService.getShopAll(); // 单号生成 this.textEdit出库单号.Text = FunctionHelper.generateBillNo("t_godown_bill", "godown_code", "CH", "00000"); }
public Frm扫码下单(Enum进出库类型 enum进出库类型) { InitializeComponent(); this.enum进出库类型 = enum进出库类型; if (this.enum进出库类型.Equals(Enum进出库类型.期初)) { this.dockPanel扫码.Text = "新建期初"; this.label扫码.Text = "请扫码创建期初"; } else if (this.enum进出库类型.Equals(Enum进出库类型.入库)) { this.dockPanel扫码.Text = "入库"; this.label扫码.Text = "请扫码入库"; } else if (this.enum进出库类型.Equals(Enum进出库类型.出库)) { this.dockPanel扫码.Text = "出库"; this.label扫码.Text = "请扫码出库"; } else if (this.enum进出库类型.Equals(Enum进出库类型.调拨)) { this.dockPanel扫码.Text = "调拨"; this.label扫码.Text = "请扫码调拨"; this.searchLookUpEdit1.Enabled = true; this.searchLookUpEdit1.Properties.DataSource = ShopService.getShopAll(); } this.gridControl1.DataSource = StockService.getStopStockAll(); this.gridView1.ExpandAllGroups(); }
public static byte[] GetCurrentShop() { byte[] objRet = null; Shop currentShop = ShopService.GetInstance().GetSingleShop(); if (currentShop != null) { //获取成功 string json = JsonConvert.SerializeObject(currentShop); byte[] jsonByte = Encoding.UTF8.GetBytes(json); int transCount = BasicTypeLength.INT32 + BasicTypeLength.INT32 + jsonByte.Length; objRet = new byte[transCount]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); Array.Copy(jsonByte, 0, objRet, 2 * BasicTypeLength.INT32, jsonByte.Length); } else { //数据库操作失败 objRet = new byte[ParamFieldLength.PACKAGE_HEAD]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_DB), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); } return(objRet); }
public async Task <bool> Execute(GameServer server, Player plr, string[] args) { await Task.Run(async() => { var message = "Reloading shop, server may lag for a short period of time..."; if (plr == null) { CommandManager.Logger.Information(message); } else { plr.SendConsoleMessage(S4Color.Green + message); } server.BroadcastNotice(message); server.ResourceCache.Clear(ResourceCacheType.Shop); await ShopService.ShopUpdateMsg(null, true); message = "Shop reload completed"; server.BroadcastNotice(message); if (plr == null) { CommandManager.Logger.Information(message); } else { plr.SendConsoleMessage(S4Color.Green + message); } }); return(true); }
public void SetUp() { _shopService = new ShopService(null, new FakeDatabaseDriver(), new List <ISupplier>() { new FakeSupplier() }); }
/// <summary> /// 点击删除按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { Alading.Entity.Shop focusShop = gridViewShop.GetFocusedRow() as Alading.Entity.Shop; if (focusShop == null) { XtraMessageBox.Show("请先选中要删除的店铺", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (XtraMessageBox.Show("是否彻底从本地删除", Constants.SYSTEM_PROMPT, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { ShopService.RemoveShop(c => c.sid == focusShop.sid); LoadShop(shopShowType); } else//不从本地彻底删除 { return; } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Query() { int?shopId = null; if (this.Shop != Globals.All) { shopId = Shop; } List = this.RollbackShopDealLogService.Query(shopId, RollbackShopDealLogState.Processing).ToList(this, x => new ListRollback(x)); var shopDealLogIds = List.Select(x => x.ShopDealLogId).ToArray(); var shopDealLogs = ShopDealLogService.GetByIds(shopDealLogIds.ToArray()); var shops = ShopService.Query(new ShopRequest() { State = ShopStates.Normal }).ToList(); foreach (var rollback in List) { var shopDealLog = shopDealLogs.FirstOrDefault(x => x.ShopDealLogId == rollback.ShopDealLogId); var shop = shops.FirstOrDefault(x => x.ShopId == shopDealLog.ShopId); rollback.Shop = shop; rollback.ShopDealLog = shopDealLog; } Shop.Bind(shops.Select(x => new IdNamePair { Key = x.ShopId, Name = string.Format("{0} - {1}", x.Name, x.DisplayName) }).ToArray(), true); }
/// <summary> /// 根据情况,展示不同店铺信息 /// </summary> /// <param name="isClearGridView">是否需要清空GridView</param> /// <param name="shopType">展示店铺类型</param> public void LoadShop(ShopType shopType) { isQuery = false; gridCtrlShop.DataSource = null; ClearTextEdit(); List <Alading.Entity.Shop> shopList = new List <Alading.Entity.Shop>(); barBtnDownload.Enabled = true; barBtnDelete.Enabled = true; if (shopType == ShopType.AllShop)//加载全部店铺 { shopList = ShopService.GetAllShop(); } else { shopList = ShopService.GetShop(c => c.ShopType == (int)shopType); } //加载数据并显示到界面 if (shopList != null && shopList.Count != 0) { ShowShopDetail(shopList); //LoadShopGridView(shopList); } else { barBtnDownload.Enabled = false; barBtnDelete.Enabled = false; } }
public void AddProductAsyncShouldReturnProductCorrectly() { var options = new DbContextOptionsBuilder <IntillegioContext>() .UseInMemoryDatabase(databaseName: "Add_Product_Db") .Options; var dbContext = new IntillegioContext(options); var productBindingModel = new AdminProductBindingModel { Name = "The Empire Strikes Back", Image255X325 = "https://pictures.abebooks.com/isbn/9780345400789-uk.jpg", Price = 12.3M, Image135X135 = "https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1328866630l/555314.jpg" }; var mapper = new Mock <IMapper>(); mapper.Setup(m => m.Map <Product>(productBindingModel)) .Returns(new Product { Name = "The Empire Strikes Back", Image255X325 = "https://pictures.abebooks.com/isbn/9780345400789-uk.jpg", Price = 12.3M, Image135X135 = "https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1328866630l/555314.jpg" }); var service = new ShopService(dbContext, mapper.Object); service.AddProductAsync(productBindingModel); Assert.True(dbContext.Products.Any(n => n.Name == productBindingModel.Name)); Assert.True(dbContext.Products.Any(a => a.Image135X135 == productBindingModel.Image135X135)); Assert.True(dbContext.Products.Any(b => b.Price == productBindingModel.Price)); Assert.True(dbContext.Products.Any(c => c.Image135X135 == productBindingModel.Image135X135)); }
/// <summary> /// 查询方法 /// </summary> public void QueryCheck() { gridCtrlShop.DataSource = null; ClearTextEdit(); Func <Alading.Entity.Shop, bool> func = null; if (shopShowType == ShopType.AllShop)//加载全部店铺 { func = new Func <Alading.Entity.Shop, bool>(c => c.title.ToUpper().Contains(keyWord) || c.nick.ToUpper().Contains(keyWord)); } else { func = new Func <Alading.Entity.Shop, bool>(c => c.title.ToUpper().Contains(keyWord) || c.nick.ToUpper().Contains(keyWord) && c.ShopType == (int)shopShowType); } List <Alading.Entity.Shop> shopList = ShopService.GetShop(func); if (shopList == null || shopList.Count == 0) { return; } ShowShopDetail(shopList); }
//GET DETAILS public ActionResult Details(int id) { var svc = new ShopService(); var model = svc.GetShopByID(id); return(View(model)); }
public void OrderAndSellArticleTwoTimesTest() { Mock <Logger> logger = new Mock <Logger>(); Mock <DbDriver> dbDriver = new Mock <DbDriver>(); ShopService shopService = new ShopService(dbDriver.Object, logger.Object); var consoleOutput = new ConsoleOutput(); var articleId = 2; var maxExpectedPrices = 500; var expectedPrice = 459; var buyerId = 10; string[] expectedOutput = { "Debug: Trying to find cheapest available article with id = " + articleId, "Info: Found article with id = " + articleId, "Debug: Trying to sell article with id = " + articleId, "Info: Article with id = " + articleId + " has been sold for the price of: " + expectedPrice, "Debug: Trying to find cheapest available article with id = " + articleId, "Info: Could not find available article with id = " + articleId }; shopService.OrderArticle(articleId, maxExpectedPrices, buyerId); shopService.OrderArticle(articleId, maxExpectedPrices, buyerId); string[] actualOutput = consoleOutput.GetOutput().Replace("\n", "").Split('\r'); Assert.AreEqual(expectedOutput, actualOutput); }
public bool Execute(GameServer server, Player plr, string[] args) { Task.Factory.StartNew(() => { var message = "Reloading shop, server may lag for a short period of time..."; if (plr == null) { Console.WriteLine(message); } else { plr.SendConsoleMessage(S4Color.Green + message); } server.BroadcastNotice(message); server.ResourceCache.Clear(ResourceCacheType.Shop); ShopService.ShopUpdateMsg(null, true); message = "Shop reload completed"; server.BroadcastNotice(message); if (plr == null) { Console.WriteLine(message); } else { plr.SendConsoleMessage(S4Color.Green + message); } }); return(true); }
//GET CREATE public ActionResult Create() { var db = new ShopService(); ViewBag.ShopID = new SelectList(db.GetShops().ToList(), "ShopID", "ShopName"); return(View()); }
private ShopService CreateShopService() { var shopId = Guid.Parse(User.Identity.GetUserId()); var shopService = new ShopService(shopId); return(shopService); }
public ActionResult Edit(int id, ArtistEdit model) { var db = new ShopService(); ViewBag.ShopID = new SelectList(db.GetShops().ToList(), "ShopID", "ShopName", model.ShopID); if (!ModelState.IsValid) { return(View(model)); } if (model.ArtistID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = new ArtistService(); if (service.UpdateArtist(model)) { TempData["SaveResult"] = "The Artist was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "This Artist could not be updated."); return(View(model)); }
public void CanUseSameObserverConsistentGameStateChanges() { var gameStateService = GameStateService.Get(); gameStateService.Init(10, 0); var gameState = gameStateService.State; var stateObserverCalled = 0; void StateValidator() { stateObserverCalled++; Assert.That(gameState.Stars, Is.EqualTo(2)); Assert.That(gameState.Coins, Is.EqualTo(8)); } gameState.AddOnCoinsChanged(StateValidator); gameState.AddOnStarsChanged(StateValidator); var shopService = ShopService.Get(); shopService.BuyStars(1, 1); shopService.BuyStars(1, 1); gameState.Observer.ExecuteActions(); Assert.That(stateObserverCalled == 1, "Observer should called once as it's the same one."); }
private void Window_Loaded(object sender, RoutedEventArgs e) { _shopService = new ShopService(); FillCategoryComboBox(); FillProductListBox(); }