public async Task <bool> CreatePronunciationAsync(PronunciationForCreate pronunciationForCreate) { try { var pronunciation = _mapper.Map <Pronunciation>(pronunciationForCreate); _context.Pronunciations.Add(pronunciation); await _context.SaveChangesAsync(); return(true); } catch (Exception ex) { return(false); } }
public async Task <IActionResult> CreatePronunciation([FromBody] PronunciationForCreate input) { if (ModelState.IsValid) { var result = await _pronunciationRepository.CreatePronunciationAsync(input); if (result) { return(Ok(new { message = "success", StatusCode = 201 })); } return(BadRequest(new { message = "fail" })); } return(BadRequest(ModelState)); }