public async Task <bool> AddSubCategoryAsync(int categoryId, SubCategoryRequestObject subCategory) { var sub = _mapper.Map <SubCategory>(subCategory); var added = await _catRepo.AddSubCategoryAsync(categoryId, sub); if (!added) { return(false); } return(true); }
public async Task <IActionResult> AddSubCategory(int id, [FromBody] SubCategoryRequestObject subCategoryRequestObject) { var check = await _categoryService.IsCategoryValidAsync(id); if (!check) { return(BadRequest("No Such Category")); } var res = await _categoryService.AddSubCategoryAsync(id, subCategoryRequestObject); if (!res) { return(BadRequest("Unable to create sub - category at this time.")); } return(CreatedAtRoute("GetCategory", new { id, includeSubCategory = true }, subCategoryRequestObject)); }