Ejemplo n.º 1
0
 /// <summary>
 /// Send message about selected item to edit
 /// </summary>
 /// <param name="obj">Selected item</param>
 protected void EditItem(AtomicItem obj)
 {
     messenger.Send(new ItemEditMsg()
     {
         ItemType = ItemType,
         ID       = obj.Id
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Set selected item
        /// </summary>
        /// <param name="selectedItem">Selected item</param>
        public void SetSelectedId(AtomicItem selectedItem)
        {
            if (selectedItem != null)
            {
                selectedLinkedId = selectedItem.Id;

                if (selectedIdLabel != null)
                {
                    selectedIdLabel.Text = selectedLinkedId.ToString();
                }
            }
            else
            {
                selectedLinkedId = -1;
            }

            FormatSelectedIdText();
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public override async Task <bool> RemoveItemFromDatabase <T>(int ID)
        {
            base.RemoveItemFromDatabase <T>(ID);

            if (useInMemoryCache)
            {
                List <AtomicItem> allItems     = inMemoryCache[typeof(T)];
                AtomicItem        itemToRemove = allItems.FirstOrDefault(x => x.Id == ID);

                if (itemToRemove != null)
                {
                    allItems.Remove(itemToRemove);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                List <T> allItems     = GetAllItems <T>();
                T        itemToRemove = allItems.FirstOrDefault(x => x.Id == ID);

                if (itemToRemove != null)
                {
                    allItems.Remove(itemToRemove);
                    string tableName = registeredModules[typeof(T)];

                    return(await SaveFileAsync(allItems, tableName));
                }
                else
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 4
0
        /// <inheritdoc/>
        public override async Task <bool> EditItemInDatabase <T>(T editedItem)
        {
            base.EditItemInDatabase(editedItem);

            if (useInMemoryCache)
            {
                List <AtomicItem> allItems     = inMemoryCache[typeof(T)];
                AtomicItem        itemToUpdate = allItems.FirstOrDefault(x => x.Id == editedItem.Id);
                int itemToUpdateIndex          = allItems.IndexOf(itemToUpdate);

                allItems[itemToUpdateIndex] = editedItem;
                return(true);
            }
            else
            {
                List <T> allItems          = GetAllItems <T>();
                T        itemToUpdate      = allItems.FirstOrDefault(x => x.Id == editedItem.Id);
                int      itemToUpdateIndex = allItems.IndexOf(itemToUpdate);
                string   tableName         = registeredModules[typeof(T)];

                allItems[itemToUpdateIndex] = editedItem;
                return(await SaveFileAsync(allItems, tableName));
            }
        }