Exemple #1
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind("Id,Source,Name,FileType,Copyright,Abbreviation,Language,Note,IsActive")] Register register, IFormFile file)
        {
            // Begin get and save file.
            string contentRootPath = _env.ContentRootPath;
            string webroot         = _env.WebRootPath;

            contentRootPath = webroot;
            string uploads  = Path.Combine(contentRootPath, "uploads");
            string filePath = Path.Combine(uploads, file.FileName);

            using (Stream stream = new FileStream(filePath, FileMode.Create))
            {
                file.CopyTo(stream);
            }
            // End get and save file.

            string[] bibleText = System.IO.File.ReadAllLines(filePath);

            int lineCount = bibleText.Length;


            if (ModelState.IsValid)
            {
                _context.Add(register);
                await _context.SaveChangesAsync();

                InsertBibleText(bibleText, register);
                return(RedirectToAction(nameof(Index)));
            }

            return(View(register));
        }
Exemple #2
0
        public async void InsertBibleText(string[] bibleText, Register register)
        {
            Bible        bible        = new Bible();
            BibleContext bibleContext = new BibleContext();

            const string pattern = @"(\d{1,3}\w)\s(\d{1,3})\s(\d{1,3})\s*\d*\s*\s*([\ \S*]*)";
            //(\d{1,3}\w)\W(\d{1,3})\W(\d{1,3})\W{1,2}\d{1,7}\W{1}([\ \S*]*)";

            // Instantiate the regular expression object.
            Regex r = new Regex(pattern, RegexOptions.IgnoreCase);

            for (int i = 8; i < bibleText.Length; i++)
            {
                Match m = r.Match(bibleText[i]);

                if (m.Groups.Count >= 4)
                {
                    bible.Id               = 0;
                    bible.Version          = register.Abbreviation;
                    bible.BookChapterVerse = m.Groups[1].ToString() + "|" + m.Groups[2].ToString() + "|" + m.Groups[3].ToString();
                    bible.Book             = m.Groups[1].ToString();
                    bible.Chapter          = m.Groups[2].ToString();
                    bible.Verse            = m.Groups[3].ToString();
                    bible.BibleText        = m.Groups[4].ToString();
                    bibleContext.Add(bible);
                    await bibleContext.SaveChangesAsync();
                }
            }
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("Title,ShortTitle,Section,Colour,Id")] Book book)
        {
            if (ModelState.IsValid)
            {
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("TranslationId,BookId,ChapterNo,Id")] Chapter chapter)
        {
            if (ModelState.IsValid)
            {
                _context.Add(chapter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(chapter));
        }
        public async Task <IActionResult> Create([Bind("Title,Code,Description,HasStrongs,Id")] Translation translation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(translation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(translation));
        }
Exemple #6
0
        public async Task <IActionResult> Create([Bind("BookId,Chapter,VerseNo,Text,Id")] Verse verse)
        {
            if (ModelState.IsValid)
            {
                _context.Add(verse);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(verse));
        }