public async Task <ActionResult <Surah> > PostSurah(Surah surah) { _context.Surahs.Add(surah); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSurah", new { id = surah.SurahId }, surah)); }
public async Task <IActionResult> PutSurah(int id, Surah surah) { if (id != surah.SurahId) { return(BadRequest()); } _context.Entry(surah).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SurahExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private Surah EnsureSurahExists(int surahNumber) { var surahs = StorageService.SetOf <Surah>(); var surah = surahs.SingleOrDefault(s => s.SurahNumber == surahNumber); if (surah == null) { surah = new Surah(); surah.SurahNumber = surahNumber; surah.EnglishName = surahNumber.ToString(); //TODO add from other data source surah.ArabicName = surahNumber.ToString(); //TODO add from other data source surahs.Add(surah); StorageService.SaveChanges(); } return(surah); }
public SurahDetailPage(Surah _surah) { InitializeComponent(); BindingContext = _surah; }