コード例 #1
0
        public async Task <ActionResult <Surah> > PostSurah(Surah surah)
        {
            _context.Surahs.Add(surah);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSurah", new { id = surah.SurahId }, surah));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public SurahDetailPage(Surah _surah)
 {
     InitializeComponent();
     BindingContext = _surah;
 }