コード例 #1
0
ファイル: TafsirController.cs プロジェクト: edenmind/Quran
        public async Task <IActionResult> PutTafsir(int id, Tafsir tafsir)
        {
            if (id != tafsir.TafsirId)
            {
                return(BadRequest());
            }

            _context.Entry(tafsir).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) {
                if (!TafsirExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
 public Tafsir_Commentary(string tafsirCode, int chapter, int verse)
 {
     QuranVerseHelper.Clip(
         chapter: ref chapter,
         verse: ref verse
         );
     this.Tafsir     = SharedData.Document.TafsirDocument[tafsirCode];
     this.Chapter    = SharedData.Document.QuranDocument[chapter];
     this.Verse      = verse;
     this.Commentary = Tafsir.CommentaryForVerse(chapter, verse);
 }
コード例 #3
0
        public Tafsir Create(string tafsirFilePath)
        {
            var doc        = XDocument.Load(File.OpenText(tafsirFilePath));
            var tafsirNode = doc.Document.Root;

            string code      = tafsirNode.Element("code").Value;
            string mufassir  = tafsirNode.Element("mufassir").Value;
            string copyRight = tafsirNode.Element("copyright").Value;
            bool   isTafsir  = tafsirNode.Element("isTafsir").Value == "Y";

            Tafsir = new Tafsir(
                code: code,
                mufassir: mufassir,
                isTafsir: isTafsir,
                copyright: copyRight
                );
            ReadChapters(tafsirNode);
            return(Tafsir);
        }
コード例 #4
0
ファイル: TafsirController.cs プロジェクト: edenmind/Quran
        public async Task <ActionResult <Tafsir> > PostTafsir(Tafsir tafsir)
        {
            var tafsirs = _context.Tafsirs.ToListAsync().Result;

            var highest = 0;

            foreach (var tafsirToCheck in tafsirs)
            {
                if (tafsirToCheck.TafsirId > highest)
                {
                    highest = tafsirToCheck.TafsirId;
                }
            }

            tafsir.TafsirId = highest + 1;
            _context.Tafsirs.Add(tafsir);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTafsir", new { id = tafsir.TafsirId }, tafsir));
        }
コード例 #5
0
ファイル: CommentaryMigrator.cs プロジェクト: shahaab/QuranX
        private void MigratorCommentator(Tafsir commentator)
        {
            Logger.Debug($"Commentary {commentator.Code}");
            var commentatorViewModel = new CommentatorViewModel(
                code: commentator.Code,
                description: commentator.Mufassir);

            CommentatorWriteRepository.Write(commentatorViewModel);

            foreach (TafsirComment commentary in commentator.Comments)
            {
                var commentaryViewModel = new CommentaryViewModel(
                    commentatorCode: commentator.Code,
                    chapterNumber: commentary.VerseReference.Chapter,
                    firstVerseNumber: commentary.VerseReference.FirstVerse,
                    lastVerseNumber: commentary.VerseReference.LastVerse,
                    text: commentary.Text.Select(x => TextContent.Create(x)));
                CommentaryWriteRepository.Write(commentaryViewModel);
            }
        }