예제 #1
0
        public async Task Delete(int id)
        {
            CategoryDao categoryDao = new CategoryDao(_context);

            try
            {
                await categoryDao.AddAsync(new Category()
                {
                    CategoryId = id
                });
            }
            catch (Exception e) { }

            return;
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] CategoryViewModel categoryVm)
        {
            Category    category    = new Category();
            CategoryDao categoryDao = new CategoryDao(_context);

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                category = CategoryViewModelToCategory.Map(categoryVm);

                category.CategoryId = await categoryDao.AddAsync(category);
            }
            catch (Exception e) { }

            return(Created("category", category));
        }