Esempio n. 1
0
        public async Task <IActionResult> Create(Item item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var queriedCategory = await categoryService.GetByIdAsync(item.CategoryId);

            if (queriedCategory == null)
            {
                return(NotFound());
            }

            await itemsService.CreateAsync(item);

            await categoryService.AddItemAsync(item.CategoryId, item.Id);

            return(Ok(item));
        }