private void loadSettingsFromToken() { if (SettingToken != null) { if (SettingToken.Metadata.TryGetValue("Name", out string name)) { Name = name; } if (SettingToken.Metadata.TryGetValue("Description", out string desc)) { Description = desc; } try { if (SettingToken.Metadata.TryGetValue("ShopItems", out string shopItems)) { var tsi = JsonConvert.DeserializeObject <List <TokenShopItem> >(shopItems); foreach (var i in tsi) { i.Token = TokenFactory.GetTokenById(TokenTypes.NTP1, i.Name, TokenId, 0.0); ShopItems.Add(i); } } } catch (Exception ex) { log.Error("Cannot load list of ShopItems", ex); } } }
public SpecificItem(int id) { InitializeComponent(); item = Search.shopList.First(shopitem => shopitem.Id == id); Position itemLocation = new Position(item.Lat, item.Lng); itemImage = new Image(); //item.Img itemName.Text = item.Title; itemAddress.Text = item.Location; itemCategory.Text = item.Category; itemAvailability.Text = item.Availability; itemDiscount.Text = item.Discount; itemDescription.Text = item.Description; itemPrice.Text = item.Price.ToString(); map.MoveToRegion( MapSpan.FromCenterAndRadius( itemLocation, Distance.FromMiles(1))); var pin = new Pin { Type = PinType.Place, Position = itemLocation, Label = itemName.Text, Address = itemAddress.Text }; map.Pins.Add(pin); }
public MainWindow() { LoadSprites(); InitializeComponent(); Image ItemIcons = Image.FromFile("Graphics\\items.png"); ItemLargeIcons.Images.AddStrip(ItemIcons); ItemSmallIcons.Images.AddStrip(ItemIcons.GetThumbnailImage(ItemIcons.Width / 4, ItemIcons.Height / 4, null, IntPtr.Zero)); for (int ItemNumber = 0; ItemNumber < ShopItems.Count(); ItemNumber++) { ShopItemList.Items.Add(Language.GetString(ShopItems[ItemNumber].NameResource), ItemNumber); } Image PeopleIcons = Image.FromFile("Graphics\\people.png"); PeopleLargeIcons.Images.AddStrip(PeopleIcons); PeopleSmallIcons.Images.AddStrip(PeopleIcons.GetThumbnailImage(PeopleIcons.Width / 4, PeopleIcons.Height / 4, null, IntPtr.Zero)); PrepareBlueprint(); tabControl1.ItemSize = new Size(0, 0); // hide tab selection from the sidebar tabControl1.Region = new Region(new Rectangle(StandardTab.Left, StandardTab.Top, StandardTab.Width, StandardTab.Height)); LockGame(true); FillDebugMenu(); }
public async Task <IActionResult> PostShopItems([FromForm] ShopItems shopItems) { try { if (Request.Form.Files.Count > 0) { var file = Request.Form.Files[0]; var folderName = Path.Combine("Resources", "Images"); var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName); Random rand = new Random(); var fileName = rand.Next(1, 100000).ToString() + ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); var fullPath = Path.Combine(pathToSave, fileName); var dbPath = Path.Combine(folderName, fileName); using (var stream = new FileStream(fullPath, FileMode.Create)) { file.CopyTo(stream); } shopItems.ImageURL = dbPath; } _context.ShopItems.Add(shopItems); await _context.SaveChangesAsync(); } catch (Exception e) { return(StatusCode(500, "Internal server error")); } return(CreatedAtAction("GetShopItems", new { id = shopItems.Id }, shopItems)); }
public int Insert(ShopItems shopItem) { var item = database.Insert(shopItem); database.Commit(); return(item); }
private void GenerateItems() { //ArmorName, Defense, Price ShopItems.Add(new Armor("Leather", 4, 8)); ShopItems.Add(new Armor("BreastPlate", 8, 20)); ShopItems.Add(new Armor("Augmented Chain", 15, 45)); ShopItems.Add(new Armor("CorosPlate", 25, 60)); //WeaponName, Strength, Price ShopItems.Add(new Weapon("Recurve bow", 3, 9)); ShopItems.Add(new Weapon("BigAxe", 6, 22)); ShopItems.Add(new Weapon("XV sword", 19, 49)); ShopItems.Add(new Weapon("Arming sword", 29, 65)); //ShieldName, Defense, Price ShopItems.Add(new Shield("Wooden Shield", 3, 10)); ShopItems.Add(new Shield("Battle Shield", 8, 26)); ShopItems.Add(new Shield("Dragon Shield", 15, 40)); //PotionName,HealthRestore, Price Potions.Add(new Potion("Health Potion", 4, 5)); Potions.Add(new Potion("Strong Health Potion", 7, 7)); Potions.Add(new Potion("Great Health Potion", 14, 10)); Potions.Add(new Potion("Gold Health Potion", 19, 13)); }
private void SearchBar_Text_OnTextChanged(object sender, TextChangedEventArgs e) { if (string.IsNullOrEmpty(SearchBar_Text.Text)) { ProductList.ItemsSource = ShopItems; } else { var fil = new Filter(SearchBar_Text.Text, 0); List <ItemPair> results = ShopItems.FindAll( delegate(ItemPair bk) { return(bk.Item1.Categorie.Contains(fil.FilterName) || bk.Item2.Categorie.Contains(fil.FilterName)); } ); if (results.Count != 0) { ProductList.ItemsSource = results; } else { List <ItemPair> noresults = new List <ItemPair> { new ItemPair(new ShopItem { Name = "No Results Found", Status = " ", Price = " ", ImageSource = " " }, null) }; ProductList.ItemsSource = noresults; } } }
public override IBook BuyItem(int id) { var book = ShopItems.Single(s => s.ProductIdentificator == id); Console.WriteLine($"Вы купили {book}"); ShopItems.Remove(book); return(book); }
private void AddBonuses(ShopItems items, List <Bonus> bonuses) { for (int i = 0; i < 3; ++i) { items.Scraps.Add((Bonus)bonuses[VALUES.random.Next(0, bonuses.Count)].Clone(new Vector()), 3); } items.Scraps.Add(new FuelBonus(new Vector()), 3); }
public int Delete(ShopItems shopItem) { int num; num = database.Delete <ShopItems>(shopItem.Id); database.Commit(); return(num); }
public override IDevice BuyItem(int id) { var device = ShopItems.Single(s => s.ProductIdentificator == id); Console.WriteLine($"Вы купили {device}"); ShopItems.Remove(device); return(device); }
private void ClickGestureRecognizer_OnTapped(object sender, EventArgs e) { Label senderLabel = (Label)sender; if (senderLabel != null) { foreach (Label VARIABLE in FilterIem.Children) { if (senderLabel.Text == VARIABLE.Text) { VARIABLE.FontSize = 0.1 * (VARIABLE.FontSize) + VARIABLE.FontSize; VARIABLE.Opacity = 1; VARIABLE.TextColor = Color.FromHex("#F9FAFC"); VARIABLE.FontAttributes = FontAttributes.Bold; VARIABLE.Margin = new Thickness(0, -4, 0, 0); } else { VARIABLE.FontAttributes = FontAttributes.None; VARIABLE.FontSize = 15; VARIABLE.Opacity = 0.7; VARIABLE.Margin = new Thickness(5); } } var fil = new Filter(senderLabel.Text, 0); List <ItemPair> results = ShopItems.FindAll( delegate(ItemPair bk) { return(bk.Item1.Categorie.Contains(fil.FilterName)); } ); if (results.Count != 0) { ProductList.ItemsSource = results; } else { List <ItemPair> noresults = new List <ItemPair> { new ItemPair(new ShopItem { Name = "No Results Found", Status = " ", Price = " ", ImageSource = " " }, null) }; ProductList.ItemsSource = noresults; } //await DisplayAlert("Item Tapped", "Le Filtre : " + fil.FilterName, "OK"); } else { DisplayAlert("Label", "Label Tapped", "Ok"); } //await DisplayAlert("Item Tapped", "An item was tapped."+e.ToString(), "OK"); //Deselect Item //((ListView)sender).SelectedItem = null; //DisplayAlert("Label", "Label Tapped", "Ok"); }
public override async Task <bool> ActivateAsync(IPost n, IShell shell, Server core) { if (n.Text is string text) { if (text.Contains("所持金")) { var balance = core.Storage[n.User].Get("economy.balance", 0); await shell.ReplyAsync(n, $"{core.GetNicknameOf(n.User)}の所持金は,{balance} クォーツです"); return(true); } if (text.IsMatch("[買か]い(物|もの)|ク[オォ]ーツショップ")) { var builder = new StringBuilder(); builder.AppendLine("ようこそクォーツショップへ.お取り扱いしている商品はこちらです"); builder.AppendLine(string.Join("\n\n", ShopItems.Select(i => $"{i.DisplayName} {i.Price}クォーツ\n {i.Description}"))); builder.Append("欲しい商品があったら,「〜〜をください」って話しかけてくださいね"); await shell.ReplyAsync(n, builder.ToString()); return(true); } var mention = StringExtension.RegexMentions.ToString(); var m1 = Regex.Match(text, $@"({mention})[にへ](\d+)ク[オォ]ーツを?送金"); var m2 = Regex.Match(text, $@"(\d+)ク[オォ]ーツを? *({mention}) *[にへ]送金"); if (m1.Success) { await TransferQuartzAsync(m1.Groups[1].Value, m1.Groups[2].Value, n, shell, core); } else if (m2.Success) { await TransferQuartzAsync(m2.Groups[2].Value, m2.Groups[1].Value, n, shell, core); } foreach (var item in ShopItems) { if (text.TrimMentions().IsMatch($"^{Regex.Escape(item.DisplayName)}を(ください|ちょうだい|くれ|頂戴)")) { string res; if (HasItem(n.User, item.Id, core)) { res = item.DisplayName + " は既に持ってるみたいですよ"; } else if (TryUseMoney(n.User, item.Price, core)) { GiveItem(n.User, item.Id, core); res = $"お買い上げありがとうございます. ({item.DisplayName} を手に入れました)"; } else { res = "お金が足りません."; } await shell.ReplyAsync(n, res); return(true); } } } return(false); }
public override void ShowItems() { var descriptions = ShopItems.Select(s => s.ToString()); foreach (var description in descriptions) { Console.WriteLine(description); } }
private ShopItems GetRandomStuff(Tier tier) { ShopItems items = new ShopItems(); AddBonuses(items, Getters.GetDrop(tier).Keys.ToList()); AddScraps(items, tier); items.Backpack.Add(Getters.GetRandomAmmo(tier)); return(items); }
public async Task <ActionResult> DeleteConfirmed(int id) { ShopItems shopItem = await db.ShopItems.FindAsync(id); db.ShopItems.Remove(shopItem); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IActionResult> PutShopItems([FromRoute] int id, [FromForm] ShopItems shopItems) { if (id != shopItems.Id) { return(BadRequest()); } if (Request.Form.Files.Count > 0) { try { var uploads = Path.Combine(Directory.GetCurrentDirectory(), shopItems.ImageURL); if (System.IO.File.Exists(uploads)) { System.IO.File.Delete(uploads); } } catch (Exception e) { //file didnt exist } var file = Request.Form.Files[0]; var folderName = Path.Combine("Resources", "Images"); var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName); Random rand = new Random(); var fileName = rand.Next(1, 100000).ToString() + ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); var fullPath = Path.Combine(pathToSave, fileName); var dbPath = Path.Combine(folderName, fileName); using (var stream = new FileStream(fullPath, FileMode.Create)) { file.CopyTo(stream); } shopItems.ImageURL = dbPath; } _context.Entry(shopItems).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShopItemsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } }
public async Task <ActionResult> Edit([Bind(Include = "id,name,description,price,url,imgUrl,shopName,imageUrl,gender,color,type,filename")] ShopItems shopItem) { if (ModelState.IsValid) { db.Entry(shopItem).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(shopItem)); }
internal static void Menu() { bool menuAlive = true; while (menuAlive) { Wallet.ShowSumOfMoney(); Console.WriteLine("\nMain menu:\n" + "1) List items.\n" + "2) Check your cart.\n" + "3) Insert money.\n" + "4) Consume item(s).\n" + "0) Quit and get your change back.\n"); Console.Write("Choose: "); int.TryParse(Console.ReadLine(), out int select); switch (select) { case 1: ShopItems.ToBuy(); break; case 2: Cart.ShowItemsInCart(); break; case 3: Wallet.InsertCurrency(); break; case 4: Cart.ShowConsumeItems(); Console.Write("Select ID from cart to consume: "); int.TryParse(Console.ReadLine(), out int selectConsume); Cart.ConsumeItemInCart(selectConsume); break; case 0: Wallet.CountChange(); menuAlive = false; break; default: Console.WriteLine("Invalid choice. Try again."); break; } Clear(); } Console.WriteLine("\nPress any key to quit the program..."); Console.ReadKey(); }
public int InsertOrUpdate(ShopItems shopItem) { int num; if (database.Table <ShopItems>().Any(x => x.Id == shopItem.Id)) { num = database.Update(shopItem); } num = database.Insert(shopItem); database.Commit(); return(num); }
private void SortShopItems(SortType type) { switch (type) { case SortType.ASC: ShopItems = new ObservableCollection <ShopItem>(ShopItems.OrderBy(item => item.InStock)); break; case SortType.DESC: ShopItems = new ObservableCollection <ShopItem>(ShopItems.OrderByDescending(item => item.InStock)); break; } }
public EditItem(int id) { InitializeComponent(); item = Search.shopList.First(shopitem => shopitem.Id == id); itemImage = new Image(); //item.Img itemName.Text = item.Title; itemAddress.Text = item.Address; itemCategory.Text = item.Category; itemDiscount.Text = item.Discount; itemDescription.Text = item.Description; itemPrice.Text = item.Price.ToString(); }
private void ShowItems(String category) { ShopItems.Clear(); using (var context = new NinjaManagerDBEntities1()) { var shopitems = context.Item.Include("Ninja").Where(i => i.category_name == category).ToList(); context.SaveChanges(); foreach (Item i in shopitems) { ShopItems.Add(new ItemViewModel(i)); } } }
private void DeleteShopItem() { if (SelectedShopItem == null) { return; } ShopItems.Remove(SelectedShopItem); if (ShopItems.Count > 0) { SelectedShopItem = ShopItems.Last(); } }
// GET: ShopItems/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShopItems shopItem = await db.ShopItems.FindAsync(id); if (shopItem == null) { return(HttpNotFound()); } return(View(shopItem)); }
public void OnRepairSkill() { if (_selectedItem != ShopItems.Repair) { _selectedItem = ShopItems.Repair; if (Constants.instance.MUSIC_ON) { AudioSource.PlayClipAtPoint(_menuClick, Camera.main.transform.position); } OnShopItemChanged(); } }
public void PopulateItems(ShopItems.Item[] items, int playerLevel, ShopItems itemsController) { for (var i = 0; i < items.Length; i++) { var index = i; var container = Instantiate(ItemContainerPrefab, parent.transform).GetComponent <ItemContainerUI>(); var button = container.Set(items[i], playerLevel < items[i].LevelRequirement); button.onClick.AddListener(() => { itemsController.GetItem(index, items[index].Price); }); } ItemsSet = true; }
// methods private void FetchDataFromApi(ShopItemType type) { switch (type) { case ShopItemType.Food: FoodAPI foodAPI = new FoodAPI(); foodAPI.GetRandomFood(5).ForEach(ShopItems.Add); break; case ShopItemType.Movie: MovieAPI movieAPI = new MovieAPI(); ShopItems.Add(movieAPI.GetRandomMovie()); break; } }
private void DeleteItem(object parameter) { NinjaList.SelectedNinja.RemoveItem(SelectedItem); ShopItems.Remove(SelectedItem); using (var context = new LeagueOfNinjasEntities()) { context.Entry(NinjaList.SelectedNinja.ToModel()).State = EntityState.Modified; context.Entry(SelectedItem.ToModel()).State = EntityState.Deleted; context.SaveChanges(); } TempShopItems.Remove(SelectedItem); }