Пример #1
0
        /// <summary>
        /// Replaces an old <c>Shop</c>-Object with a modified one.
        /// </summary>
        /// <param name="oldShop">The <c>Shop</c>-Object that should be replaced.</param>
        /// <param name="newShop">The <c>Shop</c>-Object that should be inserted into the Collection.</param>
        public void EditShop(Shop oldShop, Shop newShop)
        {
            // Get index of old object
            int idx = Shops.IndexOf(oldShop);

            // Clone ShoppingLists-List
            var templist = ShoppingLists.ToList();

            // Query all shopping lists and update the Shop object of the Shopping lists
            foreach (ShoppingList list in templist)
            {
                if (list.Shop.ID.Equals(oldShop.ID))
                {
                    // Get index of old object
                    int listIdx = ShoppingLists.IndexOf(list);

                    // Set new shop
                    list.Shop = newShop;

                    // Remove old object from list and insert new one
                    ShoppingLists.RemoveAt(listIdx);
                    ShoppingLists.Insert(listIdx, list);
                }
            }
            // Remove old object and insert new object at the same position as the old one
            Shops.Remove(oldShop);
            Shops.Insert(idx, newShop);

            // Save data to isolated storage
            SaveShops();
            SaveShoppingLists();

            // Replace old Geofence with new one
            ServiceLocator.Current.GetInstance <GeoHelper>().ModifyGeofence(oldShop.ID, newShop);
        }
Пример #2
0
 /// <summary>
 /// Method to invoke when the Delete command is executed.
 /// </summary>
 /// <param name="parameter">The parameter of the command.</param>
 private void OnDeleteExecute(object parameter)
 {
     if (_messageService.Show("Are you sure that you want to remove the selected shop?", "Are you sure?", MessageButton.OKCancel) == MessageResult.OK)
     {
         Shops.Remove(SelectedShop);
         SelectedShop = null;
     }
 }
Пример #3
0
        /// <summary>
        ///     Removes the specified shop.
        /// </summary>
        /// <param name="shop">The shop, which must not be <c>null</c>.</param>
        public override void Remove(Shop shop)
        {
            Debug.Assert(shop != null, "House must not be null.");

            lock ( locker )
            {
                NonQuery("DELETE FROM Shops WHERE OwnerName = @0 AND Name = @1 AND WorldId = @2",
                         shop.OwnerName, shop.Name, Main.worldID);
                Shops.Remove(shop);
            }
        }
Пример #4
0
        private async void RemoveShop(object obj)
        {
            if (SelectedShop != null)
            {
                var metroWindow = Application.Current.MainWindow as MetroWindow;
                var result      = await metroWindow.ShowMessageAsync("Are you sure", "Are you sure you want to delete? ", MessageDialogStyle.AffirmativeAndNegative);

                if (result == MessageDialogResult.Affirmative)
                {
                    Shops.Remove(SelectedShop);
                }
            }
        }
 public void RemoveBuilding(Location l)
 {
     if (l.Building is Warehouse)
     {
         Warehouses.Remove(l);
         l.Building.picBox.Dispose();
         ((Warehouse)l.Building).RemoveAllvehicles();
     }
     else if (l.Building is Shop)
     {
         Shops.Remove(l);
         removeShopRadiusFromCells((Shop)l.Building);
         l.Building.picBox.Dispose();
     }
     l.Building = null;
     // Set the entity's building to null as well.
     //            l.LocationEntity.Building = null; //------------------------------------------------------------------------------
 }
Пример #6
0
        /// <summary>
        /// Removes a <c>Shop</c>-Object from the <c>Shops</c>-Collection.
        /// </summary>
        /// <param name="shop">The <c>Shop</c>-Object that should be removed from the Collection.</param>
        public void DeleteShop(Shop shop)
        {
            Shops.Remove(shop);

            // Clone ShoppingLists-List
            var templist = ShoppingLists.ToList();

            // Query all shopping lists and update the Shop object of the Shopping lists
            foreach (ShoppingList list in templist)
            {
                if (list.Shop.ID.Equals(shop.ID))
                {
                    ShoppingLists.Remove(list);
                }
            }

            // Save data to isolated storage
            SaveShops();
            SaveShoppingLists();

            // Remove Geofence
            ServiceLocator.Current.GetInstance <GeoHelper>().RemoveGeofence(shop.ID);
        }
Пример #7
0
        public async void DeleteAction(object sender)
        {
            try
            {
                Shop shop   = (Shop)sender;
                var  result = await UserDialogs.Instance.ConfirmAsync(new ConfirmConfig
                {
                    Message    = "Czy na pewno chcesz usunąć sklep " + shop.Name + "?",
                    OkText     = "Tak",
                    CancelText = "Nie",
                    Title      = "Potwierdzenie"
                });

                if (result)
                {
                    UserDialogs.Instance.ShowLoading("Usuwanie...", MaskType.Black);
                    await App.Database.DeleteShopAsync(shop);

                    UserDialogs.Instance.Toast("Usunięto sklep.");
                    Shops.Remove(shop);
                    Renumber();

                    List <Item> Items = await App.Database.GetItemsByShopAsync(shop.ShopID);

                    foreach (Item item in Items)
                    {
                        await App.Database.DeleteItemAsync(item);
                    }
                    UserDialogs.Instance.HideLoading();
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.Alert("Bład!\r\n\r\n" + ex.ToString(), "Błąd", "OK");
            }
        }
Пример #8
0
        public void UpdateDefaults()
        {
            bool needSave = false;

            if (Admins.Count == 0)
            {
                logger.Info("Adding default admin");
                Admins.AddAdmin("76561198003534614", 100);
                needSave = true;
            }
            GlobalShop = (from s in Shops where s.ShopID == 0 select s).FirstOrDefault();
            if ((GlobalShop != null) && !EnableProtection)
            {
                logger.Info("Removing global shop (EnableProtection = false)");
                Shops.Remove(GlobalShop);
                GlobalShop = null;
                needSave   = true;
            }
            else
            if ((GlobalShop == null) && EnableProtection)
            {
                logger.Info("Adding global shop");
                GlobalShop = new Shop
                {
                    ShopName     = "Serverwide Shop",
                    ShopRestocks = false,
                    ShopID       = 0,
                };
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL Day Protection",
                    SellPrice     = ProtectionPriceOneDay,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 1,
                    HandlerName   = "ProtectionShopHandler"
                });
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL week Protection",
                    SellPrice     = ProtectionPriceOneWeek,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 7,
                    HandlerName   = "ProtectionShopHandler"
                });
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL Month Protection",
                    SellPrice     = ProtectionPriceOneMonth,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 30,
                    HandlerName   = "ProtectionShopHandler"
                });
                Shops.Add(GlobalShop);
                needSave = true;
            }
            if (GlobalShop != null)
            {
                GlobalShop.GlobalShop = true;
            }
            if (needSave)
            {
                Save(true);
            }
        }
Пример #9
0
 public void RemoveShop(Shop shop)
 {
     Shops.Remove(shop);
 }
 public void DeleteShop(Shop currentshop)
 {
     Shops.Remove(currentshop);
 }