public async Task <bool> AddNewCategory(GetAllCategoriesblogViewItem category) { var url = $"/Blog/addCategory"; var json = JsonConvert.SerializeObject(category); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var result = await _httpService.ExecuteQuery(url, HttpOperationMode.POST, httpContent); return(result.IsSuccessStatusCode); }
public async Task AddCategory(GetAllCategoriesblogViewItem newCategory) { Category category = new Category(); category.CategoryName = newCategory.Category; await _categoriesRepository.Add(category); await _categoriesRepository.SaveChanges(); }
public async Task <IActionResult> AddCategory([FromBody] GetAllCategoriesblogViewItem newCategory) { await _postService.AddCategory(newCategory); return(Ok()); }