private static List <QARecord> QA_OneSentence(QA_Filter_Parameters filter)
        {
            var seq = 1;

            using (var context = new YogiApekshitContext())
            {
                return(context.QueOneSentences.Where(obj =>

                                                     (filter.Lang == "Guj"
                                    ? !string.IsNullOrEmpty(obj.Que_Guj)
                                    : !string.IsNullOrEmpty(obj.Que_Eng)
                                                     ) &&
                                                     obj.BookId == filter.BookId &&
                                                     (filter.ChapterNumber == 0 || obj.ChapterNumber == filter.ChapterNumber))
                       .OrderBy(obj => obj.BookId).ThenBy(obj => obj.ChapterNumber).ToList()
                       .Select(c => new QARecord
                {
                    Sr = seq++,
                    Que = filter.Lang == "Guj" ? c.Que_Guj : c.Que_Eng,
                    Ans = filter.Lang == "Guj" ? c.Ans_Guj : c.Ans_Eng,
                    Chapter = string.Format("{0}/{1}", filter.Lang == "Guj" ? c.Book.Code_Guj : c.Book.Code_Eng, c.ChapterNumber),
                    Exams = c.Exams,
                }).ToList());
            }
        }
        private static List <QARecord> QA_WhoWhomWhen(QA_Filter_Parameters filter)
        {
            var seq = 1;

            using (var context = new YogiApekshitContext())
            {
                var data = context.QueWhoWhomWhens.Where(obj =>
                                                         (filter.Lang == "Guj"
                                    ? !string.IsNullOrEmpty(obj.Que_Guj)
                                    : !string.IsNullOrEmpty(obj.Que_Eng)
                                                         ) &&
                                                         obj.BookId == filter.BookId &&
                                                         (filter.ChapterNumber == 0 || obj.ChapterNumber == filter.ChapterNumber))
                           .OrderBy(obj => obj.BookId).ThenBy(obj => obj.ChapterNumber).ToList()
                           .Select(c => new QARecord
                {
                    Sr  = seq++,
                    Que = filter.Lang == "Guj" ? c.Que_Guj : c.Que_Eng,
                    Who = filter.Lang == "Guj"
                                        ? "કોણ: " + c.Who_Guj
                                        : "Who: " + c.Who_Eng,

                    Whom = filter.Lang == "Guj"
                                        ? "કોને: " + c.Whom_Guj
                                        : "Whom: " + c.Whom_Eng,
                    When = filter.Lang == "Guj"
                                        ? "ક્યારે: " + c.WhenSpeaking_Guj
                                        : "When: " + c.WhenSpeaking_Eng,

                    Chapter = string.Format("{0}/{1}", filter.Lang == "Guj" ? c.Book.Code_Guj : c.Book.Code_Eng, c.ChapterNumber),
                    Exams   = c.Exams,
                }).ToList();

                data.ForEach(c =>
                {
                    c.Ans = c.Who + "<br/>" + c.Whom + "<br/>" + c.When + "<br/>";
                });

                return(data);
            }
        }
        public static IEnumerable <MenuItem> GetMenu(string lang)
        {
            var menuCounter = 0;

            var cacheKey = string.Format("Menu_{0}", lang);

            var menuItems = new List <MenuItem>();

            //if (HttpContext.Current.Cache[cacheKey] != null && HttpContext.Current.Cache[cacheKey] is List<MenuItem>)
            //{
            //    menuItems = HttpContext.Current.Cache[cacheKey] as List<MenuItem>;
            //    return menuItems;
            //}

            if (menuDictionary.ContainsKey(cacheKey) && menuDictionary[cacheKey] != null)
            {
                menuItems = menuDictionary[cacheKey];
                return(menuItems);
            }

            var mnuPrarambh = new MenuItem {
                Id = menuCounter++, Name = "Prarambh", IConClass = "fa fa-pencil", MenuItems = new List <MenuItem>()
            };

            #region Prarambh

            using (var dbContext = new YogiApekshitContext())
            {
                var prarambhBooks = dbContext.Books.Where(c => c.ExamLevelId == Constants.ExamLevels.Prarambh).ToList();
                foreach (var book in prarambhBooks)
                {
                    var mnuBook = new MenuItem {
                        Id = menuCounter++, Name = lang == "Guj" ? book.Name_Guj : book.Name_Eng, IConClass = "fa fa-pencil", IConUrl = string.Format("/Images/{0}/{1}.png", book.Code_Eng, book.Code_Eng), BookId = book.Id, ChapterNumber = 0, MenuItems = new List <MenuItem>()
                    };
                    //mnuBook.MenuItems.Add(new MenuItem { Id = menuCounter++, Name = "--- All Chapters ---", ControllerName = "QA", ActionName = "QA_By_Book_Category_Chapter", BookId = book.Id, ChapterNumber = 0, RouteValues = new { bookId = book.Id, chapterNumber = 0 } });
                    foreach (var chapter in book.BookChapters)
                    {
                        mnuBook.MenuItems.Add(new MenuItem {
                            Id = menuCounter++, Name = string.Format("{0}. {1}", chapter.ChapterNumber, lang == "Guj" ? chapter.Name_Guj : chapter.Name_Eng), ControllerName = "QA", ActionName = "QA_By_Book_Category_Chapter", BookId = book.Id, ChapterNumber = chapter.ChapterNumber.Value, Category = "All", IConUrl = string.Format("/Images/{0}/{1}.png", book.Code_Eng, book.Code_Eng), RouteValues = new { bookId = book.Id, chapterNumber = chapter.ChapterNumber }
                        });
                    }

                    mnuPrarambh.MenuItems.Add(mnuBook);
                }

                // Divider
                mnuPrarambh.MenuItems.Add(new MenuItem {
                    IsDivider = true
                });

                var categories = Enum.GetValues(typeof(Constants.Que_Categories));
                foreach (var categoryEnum in categories)
                {
                    string categoryDesc = GetEnumDescription((Constants.Que_Categories)categoryEnum, lang);

                    if (categoryDesc == "All")
                    {
                        continue;
                    }

                    var menucategory = new MenuItem {
                        Id = menuCounter++, Name = categoryDesc.Replace("_", " "), MenuItems = new List <MenuItem>()
                    };
                    foreach (var book in prarambhBooks)
                    {
                        menucategory.MenuItems.Add(new MenuItem
                        {
                            Id            = menuCounter++,
                            Name          = lang == "Guj" ? book.Name_Guj : book.Name_Eng,
                            IConClass     = string.Format("/Images/{0}/{1}-mnu.png", book.Code_Eng, book.Code_Eng),
                            IConUrl       = string.Format("/Images/{0}/{1}.png", book.Code_Eng, book.Code_Eng),
                            BookId        = book.Id,
                            ChapterNumber = 0,
                            Category      = categoryEnum.ToString()
                        });
                    }

                    mnuPrarambh.MenuItems.Add(menucategory);
                }
            }
            menuItems.AddRange(mnuPrarambh.MenuItems);
            #endregion

            if (menuDictionary.ContainsKey(cacheKey))
            {
                menuDictionary.Remove(cacheKey);
            }

            menuDictionary.Add(cacheKey, menuItems);

            //HttpContext.Current.Cache.Insert(cacheKey,
            //                       menuItems,
            //                       null,
            //                       System.Web.Caching.Cache.NoAbsoluteExpiration,
            //                       TimeSpan.FromDays(10));//Data will be cached for 10 days;

            return(menuItems);
        }
        private static QA_VM QA_List(QA_Filter_Parameters filter)
        {
            var qa_vm     = new QA_VM();
            var qaRecords = new List <QARecord>();

            using (var context = new YogiApekshitContext())
            {
                if (filter.BookId > 0)
                {
                    var book = context.Books.Where(c => c.Id == filter.BookId).FirstOrDefault();
                    qa_vm.BookTitle = book != null
                                        ? filter.Lang == "Guj" ? book.Name_Guj : book.Name_Eng
                                        : string.Empty;
                }

                if (filter.ChapterNumber > 0)
                {
                    var chapter = context.BookChapters.Where(c => c.Id == filter.ChapterNumber).FirstOrDefault();
                    qa_vm.ChapterTitle = chapter != null
                                        ? filter.Lang == "Guj" ? chapter.Name_Guj : chapter.Name_Eng
                                        : string.Empty;
                }
            }

            var category = (Constants.Que_Categories)Enum.Parse(typeof(Constants.Que_Categories), filter.Category);

            switch (category)
            {
            case Constants.Que_Categories.One_Sentence:
                qa_vm.Color = "#16a085";
                qaRecords   = QA_OneSentence(filter); break;

            case Constants.Que_Categories.Correct_Option:
                qa_vm.Color = "#e05d6f";
                qaRecords   = QA_CorrectOption(filter); break;

            case Constants.Que_Categories.Correct_Sentence:
                qa_vm.Color = "#418bca";
                qaRecords   = QA_CorrectSentence(filter); break;

            case Constants.Que_Categories.Correct_Sequence:
                qa_vm.Color = "#56b1bf";
                qaRecords   = QA_CorrectSequence(filter); break;

            case Constants.Que_Categories.Fill_In_Blank:
                qa_vm.Color = "#5cb85c";
                qaRecords   = QA_FillInBlank(filter); break;

            case Constants.Que_Categories.Kirtan:
                qa_vm.Color = "#f0ad4e";
                qaRecords   = QA_Kirtan(filter); break;

            case Constants.Que_Categories.Reason:
                qa_vm.Color = "#d9534f";
                qaRecords   = QA_Reason(filter); break;

            case Constants.Que_Categories.Short_Note:
                qa_vm.Color = "#afae8b";
                qaRecords   = QA_ShortNote(filter); break;

            case Constants.Que_Categories.Swamini_Vaato:
                qa_vm.Color = "#116f7d";
                qaRecords   = QA_SwaminiVat(filter); break;

            case Constants.Que_Categories.Who_Whom_When:
                qa_vm.Color = "#d0aa90";
                qaRecords   = QA_WhoWhomWhen(filter); break;

            default:
                qaRecords = new List <QARecord>(); break;
            }

            qa_vm.QARecords = qaRecords;
            return(qa_vm);
        }