public async Task <IActionResult> UpdateItemCategory(int id, ItemCategoryForDetailDto itemCategoryForDetailDto)
        {
            var itemCategoryFromRepository = await _invRepo.Get <ItemCategory>(id);

            if (itemCategoryFromRepository == null)
            {
                return(BadRequest("Item category not available"));
            }

            if (await _context.ItemCategories.AnyAsync(a => a.Code == itemCategoryForDetailDto.Code && a.Id != id))
            {
                return(BadRequest("item Category Exist"));
            }

            itemCategoryFromRepository.Code        = itemCategoryForDetailDto.Code.ToUpper();
            itemCategoryFromRepository.Description = itemCategoryForDetailDto.Description;


            if (await _invRepo.SaveAll())
            {
                return(NoContent());
            }

            throw new System.Exception($"Updating Item Category {id} failed on save");
        }
        public async Task <IActionResult> CreateItemCategory(ItemCategoryForDetailDto itemCategoryForDetailDto)
        {
            if (await _context.ItemCategories.AnyAsync(a => a.Code == itemCategoryForDetailDto.Code))
            {
                return(BadRequest("item Category Exist"));
            }

            ItemCategory catToCreate = new ItemCategory();

            catToCreate.Code        = itemCategoryForDetailDto.Code.ToUpper();
            catToCreate.Description = itemCategoryForDetailDto.Description;

            _invRepo.Add <ItemCategory>(catToCreate);

            if (await _invRepo.SaveAll())
            {
                return(Ok());
            }

            throw new System.Exception($"Failed to Create Item category on save");
        }