public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description")] InventoryItemCategory inventoryItemCategory)
        {
            if (id != inventoryItemCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(inventoryItemCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InventoryItemCategoryExists(inventoryItemCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(inventoryItemCategory));
        }
Ejemplo n.º 2
0
 public InventoryItemType(string id, string name, InventoryItemCategory type, bool isRechargeable, int defaultAmount, int maxAmount)
 {
     Id             = id;
     Name           = name;
     Category       = type;
     IsRechargeable = isRechargeable;
     DefaultAmount  = defaultAmount;
     MaxAmount      = maxAmount;
 }
Ejemplo n.º 3
0
        public void AddCategory(InventoryItemCategoriesDto value)
        {
            var inventoryItemCategories = new InventoryItemCategory();

            inventoryItemCategories.ID          = value.ID;
            inventoryItemCategories.Name        = value.Name;
            inventoryItemCategories.Description = value.Description;

            this.iInventoryItemCategoriesDataService.AddCategory(inventoryItemCategories);
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] InventoryItemCategory inventoryItemCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(inventoryItemCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(inventoryItemCategory));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> CreateCategory(InventoryItemCategory item)
        {
            if (!User.IsInRole("Manager"))
            {
                RedirectToAction(nameof(Index));
            }
            await _context.InventoryItemCategories.AddAsync(item);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(ListCategories)));
        }
Ejemplo n.º 6
0
        public static bool CategoryIsTech(InventoryItemCategory category)
        {
            switch (category)
            {
            case InventoryItemCategory.Unknown:
            case InventoryItemCategory.Product:
            case InventoryItemCategory.Substance:
                return(false);

            default:
                return(true);
            }
        }
Ejemplo n.º 7
0
        private void PopulatePurchasedItems(InventoryItemCategory itemsCategory)
        {
            Log.Debug("Selected category {0}", Enum.GetName(typeof(InventoryItemCategory), itemsCategory));

            Log.Debug("Purchased items of category {0}: {1}",
                      Enum.GetName(typeof(InventoryItemCategory), itemsCategory),
                      purchasedItems.Where(x => x.Category == itemsCategory).Count());

            GameObject previousStoreItem = null;
            foreach (var item in purchasedItems.Where(x => x.Category == itemsCategory))
            {
                var storeItem = NGUITools.AddChild(purchasedItemsScrollView, purchasedItemTemplate);
                storeItem.SingleChild().GetComponentOrThrow<UISprite>().spriteName = item.ThumbnailName;

                // Capture index for the anonimous delegate closure
                var capturedId = item.Id;
                UIEventListener.Get(storeItem.GetComponentOrThrow<UIButton>().gameObject).onClick += (obj) =>
                {
                    if (item.Category == InventoryItemCategory.Aircraft) Game_AircraftSelected(capturedId);
                    else Game_PurchasedItemSelected(capturedId);
                };

                var storeItemSprite = storeItem.GetComponentOrThrow<UISprite>();

                storeItemSprite.topAnchor.target = purchasedItemsScrollView.transform;
                storeItemSprite.topAnchor.absolute = 0;

                storeItemSprite.bottomAnchor.target = purchasedItemsScrollView.transform;
                storeItemSprite.topAnchor.absolute = 0;

                if (previousStoreItem == null)
                {
                    // Most left item in the scroll view
                }
                else
                {
                    storeItemSprite.leftAnchor.target = previousStoreItem.transform;
                    storeItemSprite.leftAnchor.absolute = 0;
                    storeItemSprite.leftAnchor.relative = 1f;
                }

                storeItemSprite.updateAnchors = UIRect.AnchorUpdate.OnUpdate;

                storeItemSprite.ResetAndUpdateAnchors();

                previousStoreItem = storeItem;
            }

            purchasedItemsScrollView.GetComponentOrThrow<UIScrollView>().ResetPosition();
        }
        public bool CreateInventoryItemCategory(InventoryItemCategoryCreate model)
        {
            var entity = new InventoryItemCategory()
            {
                InventoryItemCategoryId = model.InventoryItemCategoryId,
                CategoryName            = model.CategoryName
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.InventoryItemCategories.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
 public bool InsertUpdateInventoryItemCategory(InventoryItemCategory item)
 {
     return(new DLInventoryItemCategory().InsertUpdateObject(item));
 }
Ejemplo n.º 10
0
 private static bool IsInventoryCodeTypeTech(InventoryItemCategory codeType)
 {
     return(!((codeType == InventoryItemCategory.Product) || (codeType == InventoryItemCategory.Substance)));
 }
Ejemplo n.º 11
0
 public bool IsItemTypeCategoryAllowed(InventoryItemCategory codeType)
 {
     return(_allowedCategories.Contains(codeType));
 }
 public void AddCategory(InventoryItemCategory inventoryItemCategory)
 {
     databaseContext.InventoryItemCategory.Add(inventoryItemCategory);
     databaseContext.SaveChanges();
 }