//Return all visible items based on selected catergory
    public List <Item> GetItems(ItemsCategory currentCategory)
    {
        List <Item> items = new List <Item>();

        switch (currentCategory)
        {
        case ItemsCategory.All:
            items = GetItems(typeof(Item));
            break;

        case ItemsCategory.Potion:
            items = GetItems(typeof(Potion));
            break;

        case ItemsCategory.Weapon:
            items = GetItems(typeof(Weapon));
            break;

        case ItemsCategory.Armor:
            items = GetItems(typeof(Armor));
            break;

        default:
            Debug.LogError("Tried to get unknown category");
            break;
        }
        return(items);
    }
        public async Task <IActionResult> PutCategoriaProducto(int id, ItemsCategory categoriaProducto)
        {
            if (id != categoriaProducto.Id)
            {
                return(BadRequest());
            }

            _context.Entry(categoriaProducto).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoriaProductoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <ItemsCategory> > PostCategoriaProducto(ItemsCategory categoriaProducto)
        {
            _context.ItemsCategories.Add(categoriaProducto);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCategoriaProducto", new { id = categoriaProducto.Id }, categoriaProducto));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,IsDeleted,DeletedOn,Id,CreatedOn,ModifiedOn")] ItemsCategory itemsCategory)
        {
            if (id != itemsCategory.Id)
            {
                return(this.NotFound());
            }

            if (this.ModelState.IsValid)
            {
                try
                {
                    this.dataRepository.Update(itemsCategory);
                    await this.dataRepository.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!this.ItemsCategoryExists(itemsCategory.Id))
                    {
                        return(this.NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(this.RedirectToAction(nameof(this.Index)));
            }

            return(this.View(itemsCategory));
        }
Example #5
0
    public void SelectPreviousCategory()
    {
        if (PreviousCategory(selectedCategory) == null)
        {
            Debug.LogError("Unkown Category");
        }

        selectedCategory = PreviousCategory(selectedCategory).Value;
        onInventoryUpdate?.Invoke();
    }
Example #6
0
        public async Task <IActionResult> Create([Bind("Name,IsDeleted,DeletedOn,Id,CreatedOn,ModifiedOn")] ItemsCategory itemsCategory)
        {
            if (this.ModelState.IsValid)
            {
                await this.dataRepository.AddAsync(itemsCategory);

                await this.dataRepository.SaveChangesAsync();

                return(this.RedirectToAction(nameof(this.Index)));
            }

            return(this.View(itemsCategory));
        }
Example #7
0
        async Task ExecuteLoadCategoryItemsCommand()
        {
            IsBusy = true;
            ItemsCategory.Clear();

            try
            {
                var items = await RestServiceCategory.RefreshDataAsync();

                items.ForEach(category => ItemsCategory.Add(category));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
                PresentBudgetChart(ItemsCategory);
            }
        }
Example #8
0
    //Utility function to get the previous Category
    ItemsCategory?PreviousCategory(ItemsCategory category)
    {
        //ItemsCategory.
        switch (category)
        {
        case ItemsCategory.All:
            return(ItemsCategory.Potion);

        case ItemsCategory.Armor:
            return(ItemsCategory.Weapon);

        case ItemsCategory.Potion:
            return(ItemsCategory.Armor);

        case ItemsCategory.Weapon:
            return(ItemsCategory.All);

        default:
            Debug.LogError("Unknown Category");
            return(null);
        }
    }
Example #9
0
 public void SelectShopType(ShopType newShopType)
 {
     selectedCategory = ItemsCategory.All;
     onInventoryUpdate?.Invoke();
 }
Example #10
0
 public void SelectCategory(ItemsCategory catergory)
 {
     DeselectItem();
     selectedCategory = catergory;
     onInventoryUpdate?.Invoke();
 }