public async Task <IActionResult> Index([FromBody] CreateTopicViewModel vm) { if (!ModelState.IsValid) { return(BadRequest(ModelState.Values.Select(v => v.Errors))); } var categoryExist = await _categoriesRepository.Contains(vm.CategoryId); if (categoryExist) { var topic = _mapper.Map <Topic>(vm); await _topicsRepository.AddAsync(topic); return(Ok()); } return(BadRequest()); }