public async Task Delete(int id) { CategoryDao categoryDao = new CategoryDao(_context); try { await categoryDao.AddAsync(new Category() { CategoryId = id }); } catch (Exception e) { } return; }
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)); }