public async Task <IActionResult> UpdatePronunciation(int id, [FromBody] PronunciationForUpdate input) { if (ModelState.IsValid) { var result = await _pronunciationRepository.UpdatePronunciationAsync(id, input); if (result) { return(Ok(new { message = "success", StatusCode = 200 })); } return(BadRequest(new { message = "fail" })); } return(BadRequest(ModelState)); }
public async Task <bool> UpdatePronunciationAsync(int id, PronunciationForUpdate pronunciationForUpdate) { var pronunciation = await GetPronunciationByIdAsync(id); if (pronunciation == null) { return(false); } try { pronunciation.FlashcardId = pronunciationForUpdate.FlashcardId; pronunciation.Link = pronunciationForUpdate.Link; pronunciation.Phonetic = pronunciationForUpdate.Phonetic; await _context.SaveChangesAsync(); return(true); } catch (Exception ex) { return(false); } }