示例#1
0
        public ActionResult Verse(int id)
        {
            if (Session["Username"] == null)
                return RedirectToAction("Index", "Admin");

            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.BibleID = id;
            btvm.TopicList = repo.GetAllTopics();
            // Get Topic IDs related to this verse
            btvm.TopicIDs = repo.GetTopicIDsPerBibleID(id);
            List<Topic> AddedTopicListTemp = new List<Topic>();
            List<Topic> AddedTopicList = new List<Topic>();
            List<string> topicNames = new List<string>();
            foreach (int item in btvm.TopicIDs)
            {
                AddedTopicListTemp.Add(repo.GetTopic(item));
            }
            // Sort topic by alphabetical order
            AddedTopicList = AddedTopicListTemp
                .OrderBy(row => row.Name)
                .ToList();
            foreach (var item in AddedTopicList)
            {
                topicNames.Add(item.Name);
            }
            btvm.AddedTopic = string.Join(", ", topicNames);

            // Get bible verse
            btvm.BibleBooksVM = new BibleBooksViewModel();
            btvm.Bible = repo.GetBible(id);
            SplitTopic(btvm);
            btvm.VerseMessage = btvm.Bible.Message;

            return View(btvm);
        }
示例#2
0
        public ActionResult Index()
        {
            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.TopicLetters = repo.GetAllTopicsInitialLetters();

            return View(btvm);
        }
示例#3
0
        public ActionResult Show(BibleTopicsViewModel modelUpdate)
        {
            if (modelUpdate.SearchKeyword == null)
                return RedirectToAction("Index", "Home");
            string keyword = modelUpdate.SearchKeyword;

            return RedirectToRoute("FrontSearch", new { action = "Search", id = keyword });
        }
示例#4
0
        public ActionResult Create()
        {
            if (Session["Username"] == null)
                return RedirectToAction("Index", "Admin");

            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.BibleBooksVM = new BibleBooksViewModel();

            btvm.TopicList = repo.GetAllTopics();

            return View(btvm);
        }
示例#5
0
        public ActionResult Show(string id)
        {
            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.TopicLetters = repo.GetAllTopicsInitialLetters();
            ViewBag.PageName = "All Letter " + id + " Topics";
            ViewBag.Letter = id;

            btvm.TopicList = repo.GetAllTopicsByLetter(id);

            TopicListing(btvm);

            return View(btvm);
        }
示例#6
0
        public ActionResult Search(string id)
        {
            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            string keyword = id;
            ViewBag.PageName = "Search Result for " + keyword;
            ViewBag.Keyword = keyword;
            btvm.TopicLetters = repo.GetAllTopicsInitialLetters();

            btvm.TopicList = repo.GetAllTopicsByKeyword(keyword);

            TopicListing(btvm);

            return View(btvm);
        }
示例#7
0
 public ActionResult Topic(int id, BibleTopicsViewModel updateModel, string confirmUpdate)
 {
     // Check if topic already exist
     if (repo.CheckTopic(updateModel.Topic.Name))
         return RedirectToRoute("Edit", new { action = "Topic", id = id, alreadyExist = true });
     BibleTopicsViewModel btvm = new BibleTopicsViewModel();
     btvm.Topic = repo.GetTopic(id);
     if (TryUpdateModel(btvm))
     {
         repo.Save();
         return RedirectToRoute("Edit", new { action = "Topic", id = id });
     }
     return RedirectToRoute("Edit", new { action = "Topic", id = id });
 }
示例#8
0
        public ActionResult SearchKeyword(string keyword, int count)
        {
            //JavaScriptSerializer jss = new JavaScriptSerializer();
            //List<Topic> topics = repo.GetAllTopTenTopicsByKeyword(keyword);

            //List<SelectedTopic> selectedTopics = new List<SelectedTopic>();
            //foreach (Topic item in topics)
            //{
            //    SelectedTopic topic = new SelectedTopic { ID = item.ID, Name = item.Name };
            //    selectedTopics.Add(topic);
            //}
            //string json = jss.Serialize(selectedTopics);
            //return new JsonResult() { Data = json };

            BibleTopicsViewModel btvm = new BibleTopicsViewModel();

            btvm.TopicList = repo.GetAllTopTopicsByKeyword(keyword, count);
            return View(btvm);
        }
示例#9
0
        public ActionResult Topic(int id, bool alreadyExist = false)
        {
            if (alreadyExist == true)
                ViewBag.AlreadyExist = alreadyExist;
            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.Topic = repo.GetTopic(id);
            // Get Bible IDs related to this topic
            btvm.BibleIDs = repo.GetBibleIDsPerTopicID(id);
            // Get all the verse related to this topic
            List<Bible> BibleListTemp = new List<Bible>();
            btvm.BibleList = new List<Bible>();
            foreach (int item in btvm.BibleIDs)
            {
                BibleListTemp.Add(repo.GetBible(item));
            }
            btvm.BibleList = BibleListTemp
                .OrderBy(row => row.BookID)
                .ToList();

            return View(btvm);
        }
示例#10
0
        public ActionResult Verses(int id)
        {
            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.TopicLetters = repo.GetAllTopicsInitialLetters();
            int topicID = id;
            string topicName = repo.GetTopicName(id);

            ViewBag.TopicName = topicName;
            ViewBag.PageName = "Verses for " + topicName;

            btvm.VerseWithTopics = new Dictionary<Bible, List<Topic>>();

            // Get bible verses for this topic
            List<int> bibleIDs = repo.GetAllOrderedVersesByTopicID(topicID);
            Bible verseTemp = new Bible();
            List<int> topicIDs = new List<int>();
            List<Topic> topicsTemp = new List<Topic>();
            List<Topic> topicsAlphaTemp = new List<Topic>();
            Topic sameTopicName;
            foreach (int bibleID in bibleIDs)
            {
                verseTemp = repo.GetBible(bibleID);
                topicIDs = repo.GetTopicIDsPerBibleID(verseTemp.ID);
                foreach (int t_ID in topicIDs)
                {
                    sameTopicName = repo.GetTopic(t_ID);
                    if (sameTopicName.Name == topicName)
                        continue;
                    topicsTemp.Add(repo.GetTopic(t_ID));
                }
                topicsAlphaTemp = topicsTemp.OrderBy(x => x.Name).ToList();
                topicsTemp.Clear();
                btvm.VerseWithTopics.Add(verseTemp, topicsAlphaTemp);
            }

            return View(btvm);
        }
示例#11
0
        public ActionResult Verses(int page, BibleTopicsViewModel modelUpdates)
        {
            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.BibleBooksVM = new BibleBooksViewModel();
            btvm.GetPages = modelUpdates.GetPages;

            int perPage;
            if (modelUpdates.GetPages != "All")
            {
                perPage = Convert.ToInt32(modelUpdates.GetPages);
                btvm.TotalPages = LoadPages(perPage);
                btvm.BibleList = repo.GetBibleVersesPerPage(page, perPage);
            }
            else
            {
                btvm.BibleList = repo.GetAllBibleVerses();
                return View(btvm);
            }

            return RedirectToRoute("AdminList", new { action = "Verses", page = 1, show = modelUpdates.GetPages });
        }
示例#12
0
        public ActionResult Verses(int page, string show = "7")
        {
            //if (Session["Username"] == null)
            //    return RedirectToAction("Index", "Admin");

            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.BibleBooksVM = new BibleBooksViewModel();

            Pagination p = new Pagination();
            Page newPage = p.Pager(page, show, repo.GetBibleVerseCount(), 10);

            btvm.GetPages = newPage.GetPages;
            btvm.PageNumbers = newPage.PageNumbers;
            btvm.CurrentPage = newPage.CurrentPage;
            btvm.TotalPages = newPage.TotalPages;
            btvm.PageRange = newPage.PageRange;
            btvm.PageRangeHalf = newPage.PageRangeHalf;
            btvm.EndPage = newPage.EndPage;

            // Count all verses, page numbers
            //btvm.GetPages = show;
            //int perPage = Convert.ToInt32(show);
            //btvm.TotalPages = LoadPages(perPage);
            //btvm.ClickedPage = page;

            //btvm.PageNumbers = new List<int>();
            //int pageRange = 7;
            //int startPage;
            //int endPage;
            //if (btvm.TotalPages <= 7)
            //{
            //    for (int i = 1; i <= btvm.TotalPages; i++)
            //    {
            //        btvm.PageNumbers.Add(i);
            //    }
            //}
            //else
            //{
            //    // When pages 1, 2, 3, 4 is clicked; no back arrow
            //    if (page <= 4)
            //    {
            //        ViewBag.EndPage = page;
            //        for (int i = 1; i <= pageRange; i++)
            //        {
            //            btvm.PageNumbers.Add(i);
            //        }
            //    }
            //    else
            //    {
            //        // When 5 or more pages are clicked
            //        startPage = page - 3;
            //        endPage = page + 3;
            //        if (page >= btvm.TotalPages - 3)
            //            startPage = btvm.TotalPages - 6;
            //        if (endPage > btvm.TotalPages)
            //            endPage = btvm.TotalPages;
            //        ViewBag.StartPage = startPage;
            //        ViewBag.EndPage = endPage;
            //        for (int i = startPage; i <= endPage; i++)
            //        {
            //            btvm.PageNumbers.Add(i);
            //        }
            //    }
            //}

            btvm.BibleList = repo.GetBibleVersesPerPage(page, newPage.ListPerPage);

            return View(btvm);
        }
示例#13
0
        public ActionResult Index(BibleTopicsViewModel modelUpdate)
        {
            string keyword = modelUpdate.SearchKeyword;

            return RedirectToRoute("FrontSearch", new { action = "Search", id = keyword });
        }
示例#14
0
 //[HttpPost]
 //public ActionResult Verse(int id, BibleTopicsViewModel updateModel, string updateConfirm)
 //{
 //    BibleTopicsViewModel btvm = new BibleTopicsViewModel();
 //    int topicID;
 //    int bibleID = id;
 //    btvm.Bible = repo.GetBible(id);
 //    // For Topic
 //    List<int> topicIDs = repo.GetTopicIDsPerBibleID(id);
 //    List<string> previousTopics = new List<string>();
 //    List<string> currentTopics = new List<string>();
 //    foreach (int item in topicIDs)
 //    {
 //        previousTopics.Add(repo.GetTopicName(item));
 //    }
 //    string[] currentTopicsTemp = Regex.Split(updateModel.AddedTopic, ", ");
 //    currentTopics.AddRange(currentTopicsTemp);
 //    #region Adding Topic
 //    foreach (string item in currentTopics)
 //    {
 //        BibleTopicsViewModel btvmNew = new BibleTopicsViewModel();
 //        // Check if topic exist
 //        if (previousTopics.Contains(item))
 //            continue;
 //        // Adding a new topic
 //        if (repo.CheckTopic(item))
 //        {
 //            topicID = repo.GetTopicID(item);
 //            btvmNew.Topic = repo.GetTopic(topicID);
 //            if (btvmNew.Topic.IsValid != true)
 //                btvmNew.Topic.IsValid = true;
 //            repo.AddBibleAndTopic(bibleID, topicID);
 //            repo.Save();
 //        }
 //        else
 //        {
 //            if (ModelState.IsValid)
 //            {
 //                btvmNew.Topic = new Topic();
 //                btvmNew.Topic.Name = item;
 //                btvmNew.Topic.Created = DateTime.Now;
 //                btvmNew.Topic.IsValid = true;
 //                repo.AddNewTopic(btvmNew.Topic);
 //                repo.Save();
 //                topicID = btvmNew.Topic.ID;
 //                repo.AddBibleAndTopic(bibleID, topicID);
 //                repo.Save();
 //            }
 //        }
 //    }
 //    #endregion
 //    #region Soft Deleting a Topic
 //    foreach (string item in previousTopics)
 //    {
 //        BibleTopicsViewModel btvmNew = new BibleTopicsViewModel();
 //        // Check if topic exist
 //        if (currentTopics.Contains(item))
 //            continue;
 //        // Soft deleting the topic
 //        topicID = repo.GetTopicID(item);
 //        btvmNew.Topic = repo.GetTopic(topicID);
 //        if (!repo.CheckTopicHasVerses(topicID))
 //            btvmNew.Topic.IsValid = false;
 //        if (TryUpdateModel(btvmNew))
 //        {
 //            repo.Save();
 //        }
 //        repo.DeleteFromBibleAndTopic(bibleID, topicID);
 //        repo.Save();
 //    }
 //    #endregion
 //    btvm.Bible.Verse = updateModel.Book + " " + updateModel.BookVerse + " " + updateModel.BookVersion;
 //    int bookID = repo.GetBookID(updateModel.Book);
 //    btvm.Bible.BookID = bookID;
 //    btvm.Bible.Message = updateModel.VerseMessage;
 //    if (TryUpdateModel(btvm))
 //    {
 //        repo.Save();
 //        return RedirectToRoute("Edit", new { action = "Verse", id = id });
 //    }
 //    return RedirectToRoute("Edit", new { action = "Verse", id = id });
 //}
 private void SplitTopic(BibleTopicsViewModel btvm)
 {
     string[] splitVerse = btvm.Bible.Verse.Split(' ');
     if (splitVerse.Count() > 3)
     {
         btvm.Book = splitVerse[0] + " " + splitVerse[1];
         btvm.BookVerse = splitVerse[2];
         btvm.BookVersion = splitVerse[3];
     }
     else
     {
         btvm.Book = splitVerse[0];
         btvm.BookVerse = splitVerse[1];
         btvm.BookVersion = splitVerse[2];
     }
 }
示例#15
0
        public ActionResult Verse(int BibleID, string AddedTopic, string Book, string BookVerse, string BookVersion, string VerseMessage)
        {
            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            int topicID;
            int bibleID = BibleID;
            btvm.Bible = repo.GetBible(BibleID);

            // For Topic
            List<int> topicIDs = repo.GetTopicIDsPerBibleID(BibleID);
            List<string> previousTopics = new List<string>();
            List<string> currentTopics = new List<string>();
            foreach (int item in topicIDs)
            {
                previousTopics.Add(repo.GetTopicName(item));
            }
            string[] currentTopicsTemp = Regex.Split(AddedTopic, ", ");
            currentTopics.AddRange(currentTopicsTemp);

            #region Adding Topic
            foreach (string item in currentTopics)
            {
                BibleTopicsViewModel btvmNew = new BibleTopicsViewModel();
                // Check if topic exist
                if (previousTopics.Contains(item))
                    continue;
                // Adding a new topic
                if (repo.CheckTopic(item))
                {
                    topicID = repo.GetTopicID(item);
                    btvmNew.Topic = repo.GetTopic(topicID);
                    if (btvmNew.Topic.IsValid != true)
                        btvmNew.Topic.IsValid = true;
                    repo.AddBibleAndTopic(bibleID, topicID);
                    repo.Save();
                }
                else
                {
                    if (ModelState.IsValid)
                    {
                        btvmNew.Topic = new Topic();
                        btvmNew.Topic.Name = item;
                        btvmNew.Topic.Created = DateTime.Now;
                        btvmNew.Topic.IsValid = true;
                        repo.AddNewTopic(btvmNew.Topic);
                        repo.Save();
                        topicID = btvmNew.Topic.ID;
                        repo.AddBibleAndTopic(bibleID, topicID);
                        repo.Save();
                    }
                }
            }
            #endregion

            #region Soft Deleting a Topic
            foreach (string item in previousTopics)
            {
                BibleTopicsViewModel btvmNew = new BibleTopicsViewModel();
                // Check if topic exist
                if (currentTopics.Contains(item))
                    continue;
                // Soft deleting the topic
                topicID = repo.GetTopicID(item);
                btvmNew.Topic = repo.GetTopic(topicID);
                if (!repo.CheckTopicHasVerses(topicID))
                    btvmNew.Topic.IsValid = false;
                if (TryUpdateModel(btvmNew))
                {
                    repo.Save();
                }
                repo.DeleteFromBibleAndTopic(bibleID, topicID);
                repo.Save();
            }
            #endregion

            btvm.Bible.Verse = Book + " " + BookVerse + " " + BookVersion;
            int bookID = repo.GetBookID(Book);
            btvm.Bible.BookID = bookID;
            btvm.Bible.Message = VerseMessage;
            if (TryUpdateModel(btvm))
            {
                repo.Save();
                //return RedirectToRoute("Edit", new { action = "Verse", id = id });
                return new JsonResult() { Data = true };
            }
            //return RedirectToRoute("Edit", new { action = "Verse", id = id });
            return new JsonResult() { Data = false };
        }
示例#16
0
        public ActionResult Create(BibleTopicsViewModel updateModel)
        {
            BibleTopicsViewModel btvm = new BibleTopicsViewModel();
            btvm.Bible = new Bible();
            btvm.BibleBooksVM = new BibleBooksViewModel();
            btvm.TopicList = repo.GetAllTopics();

            btvm.Bible.Verse = updateModel.Book + " " + updateModel.BookVerse + " " + updateModel.BookVersion;
            // If verse already exist
            int bibleID;
            if (repo.CheckVerse(btvm.Bible.Verse))
            {
                bibleID = repo.GetBibleIDByVerse(btvm.Bible.Verse);
                return RedirectToRoute("Edit", new { action = "Verse", id = bibleID });
            }

            if (ModelState.IsValid)
            {
                #region Adding Verse

                int bookID = repo.GetBookID(updateModel.Book);
                btvm.Bible.Message = updateModel.VerseMessage;
                btvm.Bible.Created = DateTime.Now;
                btvm.Bible.IsValid = true;
                btvm.Bible.BookID = bookID;
                repo.AddNewVerse(btvm.Bible);
                repo.Save();
                bibleID = btvm.Bible.ID;

                #endregion

                #region Adding Topic

                int topicID;
                string[] splitTopics = Regex.Split(updateModel.AddedTopic, ", ");
                foreach (string item in splitTopics)
                {
                    Topic topic = new Topic();
                    if (repo.CheckTopic(item))
                    {
                        topicID = repo.GetTopicID(item);
                        topic = repo.GetTopic(topicID);
                        if (topic.IsValid == false)
                        {
                            topic.IsValid = true;
                            UpdateModel(topic);
                            repo.Save();
                        }
                    }
                    else
                    {
                        topic.Name = item;
                        topic.Created = DateTime.Now;
                        topic.IsValid = true;
                        repo.AddNewTopic(topic);
                        repo.Save();
                        topicID = topic.ID;
                    }
                    repo.AddBibleAndTopic(bibleID, topicID);
                    repo.Save();
                }
                return RedirectToRoute("Edit", new { action = "Verse", id = bibleID });

                #endregion
            }

            return View(btvm);
        }
示例#17
0
        private void TopicListing(BibleTopicsViewModel btvm)
        {
            // Getting the values needed for dividing topic
            double countTopic = btvm.TopicList.Count;
            double divide = countTopic / 5;
            double wholeDecimalNum = Math.Floor(divide);
            double decimalPt = divide - wholeDecimalNum;

            // Dividing topics by column
            int wholeNumber = Convert.ToInt32(Math.Ceiling(divide));
            decimalPt = Math.Round(decimalPt, 1);

            int column;
            if (decimalPt == 0.2)
            {
                column = 1;
                AddingTopicList(btvm, wholeNumber, column);
            }
            else if (decimalPt == 0.4)
            {
                column = 2;
                AddingTopicList(btvm, wholeNumber, column);
            }
            else if (decimalPt == 0.6)
            {
                column = 3;
                AddingTopicList(btvm, wholeNumber, column);
            }
            else if (decimalPt == 0.8)
            {
                column = 4;
                AddingTopicList(btvm, wholeNumber, column);
            }
            else if (decimalPt == 0.0)
            {
                column = 5;
                AddingTopicList(btvm, wholeNumber, column);
            }
        }
示例#18
0
 private List<Topic> GetColumns(BibleTopicsViewModel btvm, int skipper, int wholeNumber, int wholeNumLesser)
 {
     List<Topic> topics = btvm.TopicList
         .Skip(skipper)
         .Take(wholeNumber - wholeNumLesser)
         .ToList();
     return topics;
 }
示例#19
0
        private void AddingTopicList(BibleTopicsViewModel btvm, int wholeNumber, int column)
        {
            List<Topic> topicList1 = new List<Topic>();
            List<Topic> topicList2 = new List<Topic>();
            List<Topic> topicList3 = new List<Topic>();
            List<Topic> topicList4 = new List<Topic>();
            List<Topic> topicList5 = new List<Topic>();

            int skipper = 0;
            int skipperLess = 0;
            int counter;
            int wholeNumLesser = 0;

            counter = 1; //1
            if (counter > column) wholeNumLesser = 1;
            topicList1 = GetColumns(btvm, skipper, wholeNumber, wholeNumLesser);

            counter++; //2
            if (counter > column) wholeNumLesser = 1;
            if (counter > column + 1) skipperLess = 1;
            skipper += wholeNumber - skipperLess;
            topicList2 = GetColumns(btvm, skipper, wholeNumber, wholeNumLesser);

            counter++; //3
            if (counter > column) wholeNumLesser = 1;
            if (counter > column + 1) skipperLess = 1;
            skipper += wholeNumber - skipperLess;
            topicList3 = GetColumns(btvm, skipper, wholeNumber, wholeNumLesser);

            counter++; //4
            if (counter > column) wholeNumLesser = 1;
            if (counter > column + 1) skipperLess = 1;
            skipper += wholeNumber - skipperLess;
            topicList4 = GetColumns(btvm, skipper, wholeNumber, wholeNumLesser);

            counter++; //5
            if (counter > column) wholeNumLesser = 1;
            if (counter > column + 1) skipperLess = 1;
            skipper += wholeNumber - skipperLess;
            topicList5 = GetColumns(btvm, skipper, wholeNumber, wholeNumLesser);

            btvm.TopicList_Column1 = topicList1;
            btvm.TopicList_Column2 = topicList2;
            btvm.TopicList_Column3 = topicList3;
            btvm.TopicList_Column4 = topicList4;
            btvm.TopicList_Column5 = topicList5;
        }