Пример #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
        public static void UpdateIndicesAfterShopUpdate()
        {
            foreach (var inmate in Inmates)
            {
                var shop = Shops.SingleOrDefault(s => s.Id == inmate.ShopId);
                if (shop == null)
                {
                    inmate.ShopIndex = -1;
                }
                else
                {
                    inmate.ShopIndex = Shops.IndexOf(shop);
                }
            }

            foreach (var tool in Tools)
            {
                var shop = Shops.SingleOrDefault(s => s.Id == tool.ShopId);
                if (shop == null)
                {
                    tool.ShopIndex = -1;
                }
                else
                {
                    tool.ShopIndex = Shops.IndexOf(shop);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Method to invoke when the Edit command is executed.
        /// </summary>
        /// <param name="parameter">The parameter of the command.</param>
        private void OnEditExecute(object parameter)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("ShopIndex", Shops.IndexOf(SelectedShop));

            _navigationService.Navigate <ShopViewModel>(parameters);
            //navigationService.Navigate("/UI/Pages/ShopPage.xaml", parameters);
        }
Пример #4
0
        /// <summary>
        /// Maps domain to view model and adds to observable collection.
        /// </summary>
        /// <param name="tool"></param>
        public static void MapToolToViewModel(Tool tool)
        {
            // shop obj needed to get the shop index for the drop down menu
            var shop = Shops.SingleOrDefault(s => s.Id == tool.ShopId);

            Tools.Add(new ToolViewModel
            {
                Id          = tool.Id,
                ToolNumber  = tool.ToolNumber,
                Description = tool.Description,
                ShopId      = shop?.Id,
                ShopIndex   = Shops.IndexOf(shop)
            });
        }
Пример #5
0
        public static void MapInmateToViewModel(Inmate inmate)
        {
            // shop obj needed to get the shop index for the drop down menu
            var shop = Shops.SingleOrDefault(s => s.Id == inmate.ShopId);

            Inmates.Add(new InmateViewModel
            {
                Id        = inmate.Id,
                FirstName = inmate.FirstName,
                LastName  = inmate.LastName,
                GDCNumber = inmate.GDCNumber,
                ShopId    = inmate.ShopId,
                ShopIndex = Shops.IndexOf(shop)
            });
        }
Пример #6
0
 /// <summary>
 /// Gets the Index of a <c>Shop</c>-Object that is element of the <c>Shops</c>-Collection.
 /// </summary>
 /// <param name="shop">The <c>Shop</c>-Object, for which an index should be retrieved.</param>
 /// <returns>The Index of the passed <c>Shop</c>-Object.</returns>
 public int IndexOfShop(Shop shop)
 {
     return(Shops.IndexOf(shop));
 }