public async Task <IActionResult> Put([FromBody] ItemCategoryForm itemCategoryForm)
        {
            ItemCategory itemCategory = new ItemCategory()
            {
                Id       = itemCategoryForm.Id,
                Category = itemCategoryForm.Category
            };
            await _appDbContext.ItemCategories.AddAsync(itemCategory);

            await _appDbContext.SaveChangesAsync();

            var res = await _appDbContext.ItemCategories.
                      Select(ItemCategoryViewModel.SelectAllItemCategory).
                      ToListAsync();

            return(Ok(res));
        }
        public async Task <IActionResult> CreateAsync([FromBody] ItemCategoryForm itemCategoryForm)
        {
            try
            {
                var modelResources = _mapper.Map <ItemCategory>(itemCategoryForm);
                await _appDbContext.ItemCategories.AddAsync(modelResources);

                await _appDbContext.SaveChangesAsync();

                var res = await _appDbContext.ItemCategories.
                          Select(ItemCategoryViewModel.SelectAllItemCategory).
                          ToListAsync();

                return(Ok(res));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Beispiel #3
0
        private void categorySetupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ItemCategoryForm itemCategoryForm = new ItemCategoryForm();

            itemCategoryForm.Show();
        }