public ActionResult Index()
        {
            verifySessionforAdmin();


            List <Subjects>       lstSubject          = new SubjectsController().getSubjects();
            List <SelectListItem> lstSubjectsDropDown = new List <SelectListItem>();
            var varlstSubject = lstSubject.Select(item => new { item.SubjectName, item.SubjectID });

            lstSubjectsDropDown.Add(new SelectListItem()
            {
                Text = "Select Subject", Value = "0"
            });
            foreach (var item in varlstSubject)
            {
                lstSubjectsDropDown.Add(new SelectListItem()
                {
                    Text = item.SubjectName, Value = item.SubjectID.ToString()
                });
            }


            ViewBag.SubjectLookup = lstSubjectsDropDown;
            return(View());
        }
        public ActionResult ChaptersDetails(int SubChapID)
        {
            List <object> lstRet = new List <object>();

            lstRet = new SubjectsController().getChapterContentsByID(SubChapID);
            return(View(lstRet));
        }
        public JsonResult SaveUpdate(string Chapter)
        {
            dynamic clsChapter = JsonConvert.DeserializeObject(Chapter);

            MSSQL_DAC clsDAC = null;

            clsDAC = new MSSQL_DAC();

            List <KeyValuePair <string, object> > lstData = new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("SubjectChapterID", (clsChapter.SubjectChapterID == "" ? 0 : (int)clsChapter.SubjectChapterID)),
                new KeyValuePair <string, object>("SubjectID", (clsChapter.SubjectID == "" ? 0 : (int)clsChapter.SubjectID)),
                new KeyValuePair <string, object>("ChapterCode", Convert.ToString(clsChapter.ChapterCode)),
                new KeyValuePair <string, object>("ChapterName", Convert.ToString(clsChapter.ChapterName)),
                new KeyValuePair <string, object>("CreatedBy", (int)Session["UserID"])
            };

            clsDAC.Execute_Procedure("sp_SubjectsChaptersCRUD", lstData);
            ViewBag.Error = clsDAC.Error_Message;


            List <object> lstChapters = new List <object>();

            lstChapters = new SubjectsController().getChaptersBySubjectsID((int)clsChapter.SubjectID);
            return(Json(lstChapters, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetChaptersBySubjectID(int SubjectID)
        {
            List <object> lstChapters = new List <object>();

            lstChapters = new SubjectsController().getChaptersBySubjectsID(SubjectID);
            //lstChapters.Add(new { SubjectChaptersID = 1, ChapterCode = "P1-1", ChapterName = "Quadratics", SubjectID = 3 });
            return(Json(lstChapters, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CSSTopic(int subID = 0)
        {
            List <object> lstRet = new SubjectsController().getChapterContentsQuestionBySubjectID(subID);

            ViewBag.PastPapers = lstRet;

            return(View(lstRet));
        }
        public ActionResult PaymentWithStripe(string Cancel = null, string subID = null, string questionId = null, string SubChapID = null, string exerciseId = null, string isPastPaper = null, string variant = null)
        {
            StripeTransactionModel md = new StripeTransactionModel();

            //getting the apiContext

            System.Guid guid = System.Guid.NewGuid();

            var transactionid = guid.ToString();

            var paymentSession = this.CreatePaymentSession(transactionid, questionId, subID, SubChapID, exerciseId, isPastPaper, variant);

            PayPalInvoiceModel model = new PayPalInvoiceModel();

            model.InvoiceGUID = transactionid;
            model.QuestionID  = int.Parse(subID);
            model.RequestXML  = "Stripe Payment With Session Id = " + paymentSession.Id;
            model.PaymentID   = paymentSession.Id;

            PayPalManager payPalManager = new PayPalManager();

            payPalManager.CreatePayPalInvoice(model);

            if (variant == null)
            {
                List <Questions> lstRet = new SubjectsController().getChaptersQuesionsBySubjectsID(int.Parse(subID));

                QuestionPayment qp = new QuestionPayment();
                qp.questionid    = int.Parse(questionId);
                qp.subjbectid    = int.Parse(subID);
                qp.transactionid = transactionid;
                qp.variant       = variant;

                ChaptersController questionpayment = new ChaptersController();
                questionpayment.QuestionPaymentSave(qp);
            }
            else
            {
                QuestionPayment qp = new QuestionPayment();
                qp.questionid    = int.Parse(questionId);
                qp.subjbectid    = int.Parse(subID);
                qp.transactionid = transactionid;
                qp.variant       = variant;

                ChaptersController questionpayment = new ChaptersController();
                questionpayment.QuestionPaymentSave(qp);
            }


            md.session   = paymentSession;
            md.sessionid = paymentSession.Id;

            var StripePublishablekey = ConfigurationManager.AppSettings["StripePublishablekey"].ToString();

            md.StripePublishablekey = StripePublishablekey;

            return(View(md));
        }
        public ActionResult ChapterQuetionsEdit(int CHID, int SCID)
        {
            DataTable dt_1 = null;

            MSSQL_DAC clsDAC   = new MSSQL_DAC();
            Questions question = new Questions();


            dt_1 = clsDAC.Read_DT_Procedure("sp_GetSubjectsChapterQuestionsByQuestionID", new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("QuestionID", CHID)
            });


            if (dt_1 != null || dt_1.Rows.Count > 0)
            {
                foreach (DataRow dr_1 in dt_1.Rows)
                {
                    question.QuestionID         = Convert.ToInt32(dr_1["QuestionID"]);
                    question.URL                = dr_1["URL"] == DBNull.Value ? "" : Convert.ToString(dr_1["URL"]);
                    question.SubjectsChaptersID = (dr_1["SubjectsChaptersID"] == DBNull.Value ? 0 : Convert.ToInt32(dr_1["SubjectsChaptersID"]));
                    question.QuestionText       = dr_1["QuestionText"] == DBNull.Value ? "" : Convert.ToString(dr_1["QuestionText"]);
                    question.ImageFileName      = dr_1["ImageFileName"] == DBNull.Value ? "" : Convert.ToString(dr_1["ImageFileName"]);
                    question.VideoFileName      = dr_1["VideoFileName"] == DBNull.Value ? "" : Convert.ToString(dr_1["VideoFileName"]);
                    question.PaperYear          = dr_1["PaperYear"] == DBNull.Value ? "" : Convert.ToString(dr_1["PaperYear"]);
                    question.ImageFilePath      = dr_1["ImageFilePath"] == DBNull.Value ? "" : Convert.ToString(dr_1["ImageFilePath"]);
                    question.PdfDocFile         = dr_1["PdfDocFile"] == DBNull.Value ? "" : Convert.ToString(dr_1["PdfDocFile"]);
                    question.PdfDocFilePath     = dr_1["PdfDocFilePath"] == DBNull.Value ? "" : Convert.ToString(dr_1["PdfDocFilePath"]);
                    question.VideoFilePath      = dr_1["VideoFilePath"] == DBNull.Value ? "" : Convert.ToString(dr_1["VideoFilePath"]);
                    question.isfree             = Convert.ToBoolean(dr_1["Isfree"]);
                }
            }

            List <object> lstRet = new List <object>();

            lstRet = new SubjectsController().getChapterContentsByID(SCID);
            string ChapterName = "";
            string SubjectName = "";
            string SubjectType = "";

            if (lstRet.Count() > 0)
            {
                var ChapterContentBasic = lstRet.FirstOrDefault();
                ChapterName = Convert.ToString(ChapterContentBasic.GetType().GetProperty("ChapterName").GetValue(ChapterContentBasic));
                SubjectName = Convert.ToString(ChapterContentBasic.GetType().GetProperty("SubjectName").GetValue(ChapterContentBasic));
                SubjectType = Convert.ToString(ChapterContentBasic.GetType().GetProperty("SubjectType").GetValue(ChapterContentBasic));
            }

            ViewBag.SubjectsChaptersID = SCID;
            ViewBag.ChapterName        = ChapterName;
            ViewBag.SubjectName        = SubjectName;
            ViewBag.SubjectType        = SubjectType;


            return(View(question));
        }
Beispiel #8
0
        // GET: Chapters
        public ActionResult Chapters(int Sub)
        {
            if (Session["LoginID"] == null || Convert.ToString(Session["LoginID"]) == "")
            {
                Response.Redirect("~/Home/Index");
            }

            List <SubjectChapters> lstRet = new SubjectsController().getChaptersExerciseBySubjectsID(Sub);

            return(View(lstRet));
        }
Beispiel #9
0
        public ActionResult ChaptersDetails(int SubChapID)
        {
            if (Session["LoginID"] == null || Convert.ToString(Session["LoginID"]) == "")
            {
                Response.Redirect("~/Home/Index");
            }

            List <object> lstRet = new List <object>();

            lstRet = new SubjectsController().getChapterContentsByID(SubChapID);
            return(View(lstRet));
        }
        public ActionResult Chapters(int Sub, int IsTopical)
        {
            ChaptersViewModel vm = new ChaptersViewModel();

            List <SubjectChapters> lstRet  = new SubjectsController().getChaptersExerciseBySubjectsID(Sub);
            List <Questions>       lstRet1 = new SubjectsController().getChaptersQuesionsBySubjectsID(Sub);

            vm.SubjectChapters = lstRet;
            vm.Questions       = lstRet1;

            ViewBag.IsTopical = IsTopical;

            return(View(vm));
        }
        public ActionResult ChapterContents(int ID)
        {
            verifySessionforAdmin();

            if (Request.QueryString["ID"] != null)
            {
                QueryChapterContentID = Convert.ToInt32(Request.QueryString["ID"]);
            }
            if (ID > 0)
            {
                QueryChapterContentID = ID;
            }

            List <object> lstRet = new List <object>();

            lstRet = new SubjectsController().getChapterContentsByID(QueryChapterContentID);
            string ChapterName = "";
            string SubjectName = "";
            string SubjectType = "";

            if (lstRet.Count() > 0)
            {
                var ChapterContentBasic = lstRet.FirstOrDefault();
                ChapterName = Convert.ToString(ChapterContentBasic.GetType().GetProperty("ChapterName").GetValue(ChapterContentBasic));
                SubjectName = Convert.ToString(ChapterContentBasic.GetType().GetProperty("SubjectName").GetValue(ChapterContentBasic));
                SubjectType = Convert.ToString(ChapterContentBasic.GetType().GetProperty("SubjectType").GetValue(ChapterContentBasic));
            }

            ViewBag.SubjectsChaptersID = QueryChapterContentID;
            ViewBag.ChapterName        = ChapterName;
            ViewBag.SubjectName        = SubjectName;
            ViewBag.SubjectType        = SubjectType;
            if (lstRet != null && lstRet.Count == 1)
            {
                var ChapterContentBasic = lstRet.FirstOrDefault();
                var ContentsHolder      = Convert.ToString(ChapterContentBasic.GetType().GetProperty("ContentsHolder").GetValue(ChapterContentBasic));

                if (ContentsHolder == "0")
                {
                    lstRet.RemoveAt(0);
                }
            }


            ViewBag.ChapterContentsList = lstRet;

            return(View());
        }
        public ActionResult Index()
        {
            List <object> lstModels = new List <object>();

            lstModels.Add(new Login());
            List <Subjects> modelSubjectsList       = new SubjectsController().getSubjects();
            List <Subjects> modelSubjectsTopicsList = new SubjectsController().getSubjectTopics();

            lstModels.Add(modelSubjectsList);
            lstModels.Add(modelSubjectsTopicsList);

            if (Session["EmailSent"] == null)
            {
                try
                {
                    MVCSlider.App_Code.ExtensionMethods.SendMail();
                    Session["EmailSent"] = "Sent";
                }
                catch
                {
                }
            }

            if (Session["TotalVisitors"] == null)
            {
                try
                {
                    int Counter = MVCSlider.DAC.MSSQL_DAC.SaveVisitor();
                    Session["TotalVisitors"] = Counter;
                    ViewBag.TotalVisitors    = Counter;
                }
                catch
                {
                    ViewBag.TotalVisitors = 0;
                }
            }
            else
            {
                ViewBag.TotalVisitors = Session["TotalVisitors"] == null ? 0 : Convert.ToInt32(Session["TotalVisitors"]);
            }


            return(View("Index", "~/Views/Shared/_IndexPageLayout.cshtml", lstModels));
        }
        public JsonResult SaveDelete(int SubjectChapterID, int SubjectID)
        {
            //dynamic clsChapter = JsonConvert.DeserializeObject(Chapter);

            MSSQL_DAC clsDAC = null;

            clsDAC = new MSSQL_DAC();

            List <KeyValuePair <string, object> > lstData = new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("SubjectChapterID", SubjectChapterID),
                new KeyValuePair <string, object>("CreatedBy", (int)Session["UserID"])
            };

            clsDAC.Execute_Procedure("sp_SubjectsChaptersDelete", lstData);
            ViewBag.Error = clsDAC.Error_Message;


            List <object> lstChapters = new List <object>();

            lstChapters = new SubjectsController().getChaptersBySubjectsID(SubjectID);
            return(Json(lstChapters, JsonRequestBehavior.AllowGet));
        }
Beispiel #14
0
        public ActionResult PaymentWithPaypal(string Cancel       = null, string subID = null
                                              , string questionId = null,
                                              string SubChapID    = null, string exerciseId = null, string isPastPaper = null, string variant = null
                                              )
        {
            //var smtp = new SmtpClient
            try
            {
                //Create the msg object to be sent
                MailMessage msg = new MailMessage();
                //Add your email address to the recipients
                msg.To.Add("*****@*****.**");
                //Configure the address we are sending the mail from
                MailAddress address = new MailAddress("*****@*****.**");
                msg.From    = address;
                msg.Subject = "Clicked On Paypal Button on date time " + DateTime.Now;
                msg.Body    = "Clicked On Paypal Button on date time " + DateTime.Now;

                SmtpClient client = new SmtpClient();
                client.Host = "relay-hosting.secureserver.net";
                client.Port = 25;
                //Setup credentials to login to our sender email address ("UserName", "Password")
                client.UseDefaultCredentials = false;
                NetworkCredential credentials = new NetworkCredential("*****@*****.**", "asjad001$");
                client.Credentials = credentials;

                //Send the msg
                client.Send(msg);

                //Display some feedback to the user to let them know it was sent
                //lblResult.Text = "Your message was sent!";
            }
            catch (Exception ex)
            {
                //If the message failed at some point, let the user know
                //lblResult.Text = ex.ToString(); //alt text "Your message failed to send, please try again."
            }
            //getting the apiContext
            APIContext apiContext    = PaypalConfiguration.GetAPIContext();
            var        transactionid = "";

            try
            {
                //A resource representing a Payer that funds a payment Payment Method as paypal
                //Payer Id will be returned when payment proceeds or click to pay
                string payerId = Request.Params["PayerID"];
                if (string.IsNullOrEmpty(payerId))
                {
                    //this section will be executed first because PayerID doesn't exist
                    //it is returned by the create function call of the payment class
                    // Creating a payment
                    // baseURL is the url on which paypal sendsback the data.
                    //  string baseURI = Request.Url.Scheme + "://" + Request.Url.Authority + "/PayPal/PaymentWithPayPal?";
                    string baseURI = GetBaseUrl() + "/PayPal/PaymentWithPayPal?";
                    //here we are generating guid for storing the paymentID received in session
                    //which will be used in the payment execution
                    System.Guid guid1 = System.Guid.NewGuid();
                    var         guid  = guid1.ToString();
                    //CreatePayment function gives us the payment approval url
                    //on which payer is redirected for paypal account payment
                    var createdPayment = this.CreatePayment(apiContext, baseURI + "guid=" + guid, guid, questionId
                                                            , subID, SubChapID, exerciseId, isPastPaper
                                                            );
                    //get links returned from paypal in response to Create function call
                    var    links             = createdPayment.links.GetEnumerator();
                    string paypalRedirectUrl = null;
                    while (links.MoveNext())
                    {
                        Links lnk = links.Current;
                        if (lnk.rel.ToLower().Trim().Equals("approval_url"))
                        {
                            //saving the payapalredirect URL to which user will be redirected for payment
                            paypalRedirectUrl = lnk.href;
                        }
                    }
                    // saving the paymentID in the key guid

                    string paymentXML = Utility.Serialize <Payment>(createdPayment);

                    PayPalManager payPalManager = new PayPalManager();

                    PayPalInvoiceModel model = new PayPalInvoiceModel();

                    model.InvoiceGUID = guid;
                    model.QuestionID  = int.Parse(questionId);
                    model.RequestXML  = paymentXML;
                    model.PaymentID   = createdPayment.id;

                    if (variant == null)
                    {
                        List <Questions> lstRet = new SubjectsController().getChaptersQuesionsBySubjectsID(int.Parse(subID));

                        QuestionPayment qp = new QuestionPayment();

                        qp.questionid    = int.Parse(questionId);
                        qp.subjbectid    = int.Parse(subID);
                        qp.transactionid = transactionid;
                        qp.variant       = variant;

                        ChaptersController questionpayment = new ChaptersController();
                        questionpayment.QuestionPaymentSave(qp);
                    }
                    else
                    {
                        QuestionPayment qp = new QuestionPayment();

                        qp.questionid    = int.Parse(questionId);
                        qp.subjbectid    = int.Parse(subID);
                        qp.transactionid = transactionid;
                        qp.variant       = variant;

                        ChaptersController questionpayment = new ChaptersController();
                        questionpayment.QuestionPaymentSave(qp);
                    }

                    payPalManager.CreatePayPalInvoice(model);

                    // Session.Add(guid, createdPayment.id);
                    return(Redirect(paypalRedirectUrl));
                }
                else
                {
                    PayPalManager payPalManager = new PayPalManager();

                    // This function exectues after receving all parameters for the payment
                    var guid = Request.Params["guid"];
                    transactionid = guid;
                    try
                    {
                        var invoice = payPalManager.GetPayPalInvoiceByGUID(guid);

                        if (invoice != null)
                        {
                            var executedPayment = ExecutePayment(apiContext, payerId, invoice.PaymentID as string);

                            var response = Utility.Serialize <Payment>(executedPayment);

                            invoice.State       = executedPayment.state;
                            invoice.ResponseXML = response;

                            payPalManager.UpdatePayPalInvoice(invoice);

                            if (executedPayment.state.ToLower() != "approved")
                            {
                                return(RedirectToAction("Index", "Home"));
                                //   return View("FailureView");
                            }
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                            // return View("FailureView");
                        }
                    }
                    catch (Exception ex)
                    {
                        var exception = Utility.Serialize <Exception>(ex);
                        payPalManager.LogException(guid, exception);
                        return(RedirectToAction("Index", "Home"));
                    }
                    //If executed payment failed then we will show payment failure message to user
                }
            }
            catch (Exception ex)
            {
                //return View("FailureView");
                return(RedirectToAction("Index", "Home"));
            }
            //on successful payment, show success page to user.

            if (isPastPaper != null && isPastPaper == "1")
            {
                TempData["paymentTransactionId"] = transactionid;
                return(RedirectToAction("ChapterQuestions", "Home", new { sub = subID, questionYearId = questionId, scfp = true }));
                // return RedirectToAction("ShowVideoPastPaper", "Home", new { subID = subID, questionId = questionId, transactionid = transactionid });
            }
            else
            {
                return(RedirectToAction("ShowVideo", "Home", new { SubChapID = SubChapID, questionId = questionId, exerciseId = exerciseId, transactionid = transactionid }));
            }
        }
        public ActionResult ChapterContent(int subID = 0)
        {
            List <object> lstRet = new SubjectsController().getChapterContentsQuestionBySubjectID(subID);

            return(View(lstRet));
        }
        //  public ActionResult ShowVideo(int SubChapID, string name)
        public ActionResult ShowVideo(int SubChapID, int questionId, int exerciseId, string transactionid
                                      , string session_id = null, bool isdwn = false
                                      )
        {
            if (TempData["paymentTransactionId"] != null)
            {
                PayPalManager payPalManager = new PayPalManager();
                var           invoice       = payPalManager.GetPayPalInvoiceByGUID(Convert.ToString(TempData["paymentTransactionId"]));
                if (invoice != null)
                {
                    if (invoice.QuestionID != SubChapID)
                    {
                        ViewBag.paymentTransactionId = null;
                    }
                    else
                    {
                        ViewBag.paymentTransactionId = TempData["paymentTransactionId"];
                    }
                }
                //TempData.Keep("paymentTransactionId");
            }
            if (string.IsNullOrEmpty(transactionid))
            {
                if (isdwn == true)
                {
                    List <Questions> Question = new SubjectsController().getChaptersQuesionsByQuestionID(questionId);
                    if (Question.Select(x => x.isfree).FirstOrDefault() == true)
                    {
                        var showVideoViewModel1 = new SubjectsController().getShowVideoViewModelByID(SubChapID).FirstOrDefault();
                        var Exercises1          = new SubjectsController().getShowVideoViewModelByID(exerciseId);
                        var question1           = Exercises1.Where(x => x.ContentsHolder == questionId).FirstOrDefault();
                        ViewBag.Path = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(question1.VideoFilePath);
                        showVideoViewModel1.ExerciseName = Exercises1.FirstOrDefault().ChapterName;
                        showVideoViewModel1.QuestionText = question1.QuestionText;

                        string downloadURL1 = GetBaseUrl() + "/Home/DownloadQuestion?p1=" + questionId;
                        ViewBag.DownloadURL   = downloadURL1;
                        ViewBag.transactionid = transactionid;


                        return(View("ShowVideo", "~/Views/Shared/_IndexPageLayout.cshtml", showVideoViewModel1));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    return
                        (RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                PayPalManager payPalManager = new PayPalManager();
                var           invoice       = payPalManager.GetPayPalInvoiceByGUID(transactionid);
                if (invoice != null && invoice.RequestXML.ToLower().Contains("stripe payment"))
                {
                    if (invoice.QuestionID != questionId && session_id != invoice.PaymentID)
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    if (invoice == null || invoice.QuestionID != questionId || invoice.State != "approved")
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }

            var showVideoViewModel = new SubjectsController().getShowVideoViewModelByID(SubChapID).FirstOrDefault();
            var Exercises          = new SubjectsController().getShowVideoViewModelByID(exerciseId);
            var question           = Exercises.Where(x => x.ContentsHolder == questionId).FirstOrDefault();

            ViewBag.Path = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(question.VideoFilePath);
            showVideoViewModel.ExerciseName = Exercises.FirstOrDefault().ChapterName;
            showVideoViewModel.QuestionText = question.QuestionText;

            string downloadURL = GetBaseUrl() + "/Home/DownloadQuestion?p1=" + questionId;

            ViewBag.DownloadURL   = downloadURL;
            ViewBag.transactionid = transactionid;

            try
            {
                string strURL = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(question.VideoFilePath);
                //string strFileName = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(videoFileName);
                WebClient    req      = new WebClient();
                HttpResponse response = System.Web.HttpContext.Current.Response;
                response.Clear();
                response.ClearContent();
                response.ClearHeaders();
                response.Buffer = true;
                response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(strURL) + "\"");
                //response.AppendHeader("Content-Disposition", "attachment; filename=" + subjectName +" "+ chapterName + " " + questionText + "");
                byte[] data = req.DownloadData(Server.MapPath(strURL));
                response.BinaryWrite(data);
                response.End();
            }
            catch (Exception ex)
            {
            }

            return(View("ShowVideo", "~/Views/Shared/_IndexPageLayout.cshtml", showVideoViewModel));
        }
        public ActionResult ShowVideoPastPaper(int subID, int questionId, string transactionid, string session_id = null, bool isdwn = false, string variant = null)
        {
            if (TempData["paymentTransactionId"] != null)
            {
                PayPalManager payPalManager = new PayPalManager();
                var           invoice       = payPalManager.GetPayPalInvoiceByGUID(Convert.ToString(TempData["paymentTransactionId"]));
                if (invoice != null)
                {
                    if (invoice.QuestionID != subID)
                    {
                        ViewBag.paymentTransactionId = null;
                    }
                    else if (invoice.QuestionID == subID || variant != null)
                    {
                        List <QuestionPayment> lstQuestion = new SubjectsController().getQuesionsFromPaymentQuestion_BySubjectsIDAndTransactionAndVarient(subID, Convert.ToString(TempData["paymentTransactionId"]), variant);
                        if (lstQuestion.Count > 0)
                        {
                            if (lstQuestion.Select(x => x.create_date == DateTime.Now.Date).FirstOrDefault())
                            {
                                ViewBag.paymentTransactionId = TempData["paymentTransactionId"];
                                TempData.Keep("paymentTransactionId");
                            }
                            else
                            {
                                ViewBag.paymentTransactionId = null;
                            }
                        }
                        else
                        {
                            ViewBag.paymentTransactionId = null;
                        }
                    }
                    else
                    {
                        List <QuestionPayment> lstQuestion = new SubjectsController().getQuesionsFromPaymentQuestion_BySubjectsIDAndTransaction(subID, Convert.ToString(TempData["paymentTransactionId"]));
                        if (lstQuestion.Count > 0)
                        {
                            if (lstQuestion.Select(x => x.create_date == DateTime.Now.Date).FirstOrDefault())
                            {
                                ViewBag.paymentTransactionId = TempData["paymentTransactionId"];
                                TempData.Keep("paymentTransactionId");
                            }
                            else
                            {
                                ViewBag.paymentTransactionId = null;
                            }
                        }
                        else
                        {
                            ViewBag.paymentTransactionId = null;
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(transactionid))
            {
                if (isdwn == true)
                {
                    List <Questions> Question = new SubjectsController().getChaptersQuesionsByQuestionID(questionId);
                    if (Question.Select(x => x.isfree).FirstOrDefault() == true)
                    {
                        List <object> lstRet1             = new SubjectsController().getChapterContentsQuestionBySubjectID(subID);
                        var           showVideoViewModel1 = new ShowVideoViewModel();
                        var           videoFileName1      = "";
                        var           videoFilePath1      = "";
                        var           subjectName1        = "";
                        var           chapterName1        = "";
                        var           questionText1       = "";

                        foreach (var item in lstRet1)
                        {
                            var questionIdDB = item.GetType().GetProperty("ContentsHolder").GetValue(item, null).ToString();

                            if (questionId.ToString() == questionIdDB)
                            {
                                videoFilePath1 = item.GetType().GetProperty("VideoFilePath").GetValue(item, null).ToString();
                                videoFileName1 = item.GetType().GetProperty("VideoFileName").GetValue(item, null).ToString();
                                subjectName1   = item.GetType().GetProperty("SubjectName").GetValue(item, null).ToString();
                                chapterName1   = item.GetType().GetProperty("ChapterName").GetValue(item, null).ToString();
                                questionText1  = item.GetType().GetProperty("QuestionText").GetValue(item, null).ToString();
                            }
                        }

                        ViewBag.Path = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(videoFilePath1);


                        showVideoViewModel1.SubjectName = subjectName1;
                        showVideoViewModel1.ChapterName = chapterName1;

                        showVideoViewModel1.ExerciseName = chapterName1;
                        showVideoViewModel1.QuestionText = questionText1;

                        ViewBag.ShowVideoPastPaper = 1;

                        string downloadURL1 = GetBaseUrl() + "/Home/DownloadQuestion?p1=" + questionId;
                        ViewBag.DownloadURL   = downloadURL1;
                        ViewBag.transactionid = transactionid;

                        try
                        {
                            string       strURL      = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(videoFilePath1);
                            string       strFileName = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(videoFileName1);
                            WebClient    req         = new WebClient();
                            HttpResponse response    = System.Web.HttpContext.Current.Response;
                            response.Clear();
                            response.ClearContent();
                            response.ClearHeaders();
                            response.Buffer = true;
                            response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(videoFileName1) + "\"");
                            //response.AppendHeader("Content-Disposition", "attachment; filename=" + subjectName +" "+ chapterName + " " + questionText + "");
                            byte[] data = req.DownloadData(Server.MapPath(strURL));
                            response.BinaryWrite(data);
                            response.End();
                        }
                        catch (Exception ex)
                        {
                        }

                        return(View("ShowVideo", "~/Views/Shared/_IndexPageLayout.cshtml", showVideoViewModel1));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }
            else
            {
                PayPalManager payPalManager = new PayPalManager();
                var           invoice       = payPalManager.GetPayPalInvoiceByGUID(transactionid);

                //if (invoice == null || invoice.QuestionID != questionId || invoice.State != "approved")
                //    return RedirectToAction("Index", "Home");

                if (invoice != null && invoice.RequestXML.ToLower().Contains("stripe payment"))
                {
                    //if (invoice.QuestionID != questionId && session_id != invoice.PaymentID)
                    if (invoice.PaymentID == null)
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    //if (invoice == null || invoice.QuestionID != questionId || invoice.State != "approved")
                    if (invoice == null || invoice.State != "approved")
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }

            List <object> lstRet             = new SubjectsController().getChapterContentsQuestionBySubjectID(subID);
            var           showVideoViewModel = new ShowVideoViewModel();
            var           videoFileName      = "";
            var           videoFilePath      = "";
            var           subjectName        = "";
            var           chapterName        = "";
            var           questionText       = "";

            foreach (var item in lstRet)
            {
                var questionIdDB = item.GetType().GetProperty("ContentsHolder").GetValue(item, null).ToString();

                if (questionId.ToString() == questionIdDB)
                {
                    videoFilePath = item.GetType().GetProperty("VideoFilePath").GetValue(item, null).ToString();
                    videoFileName = item.GetType().GetProperty("VideoFileName").GetValue(item, null).ToString();
                    subjectName   = item.GetType().GetProperty("SubjectName").GetValue(item, null).ToString();
                    chapterName   = item.GetType().GetProperty("ChapterName").GetValue(item, null).ToString();
                    questionText  = item.GetType().GetProperty("QuestionText").GetValue(item, null).ToString();
                }
            }

            ViewBag.Path = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(videoFilePath);


            showVideoViewModel.SubjectName = subjectName;
            showVideoViewModel.ChapterName = chapterName;

            showVideoViewModel.ExerciseName = chapterName;
            showVideoViewModel.QuestionText = questionText;

            ViewBag.ShowVideoPastPaper = 1;

            string downloadURL = GetBaseUrl() + "/Home/DownloadQuestion?p1=" + questionId;

            ViewBag.DownloadURL   = downloadURL;
            ViewBag.transactionid = transactionid;

            try
            {
                string       strURL      = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(videoFilePath);
                string       strFileName = "/ContentStorage/ChaptersContents/" + System.IO.Path.GetFileName(videoFileName);
                WebClient    req         = new WebClient();
                HttpResponse response    = System.Web.HttpContext.Current.Response;
                response.Clear();
                response.ClearContent();
                response.ClearHeaders();
                response.Buffer = true;
                response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(videoFileName) + "\"");
                //response.AppendHeader("Content-Disposition", "attachment; filename=" + subjectName +" "+ chapterName + " " + questionText + "");
                byte[] data = req.DownloadData(Server.MapPath(strURL));
                response.BinaryWrite(data);
                response.End();
            }
            catch (Exception ex)
            {
            }

            return(View("ShowVideo", "~/Views/Shared/_IndexPageLayout.cshtml", showVideoViewModel));
        }
        public ActionResult Index(Login modelLogin)
        {
            List <object> lstModels = new List <object>();
            List <KeyValuePair <string, object> > lstData;
            DataTable dt_1   = null;
            MSSQL_DAC clsDAC = null;

            clsDAC = new MSSQL_DAC();

            ViewBag.TotalVisitors = Session["TotalVisitors"] == null ? 0 : Convert.ToInt32(Session["TotalVisitors"]);

            //---Getting Subjects
            List <Subjects> modelSubjectsList = new SubjectsController().getSubjects();

            Session["UserName"] = modelLogin.UserName;
            //---Login
            lstData = new List <KeyValuePair <string, object> >()
            {
                new KeyValuePair <string, object>("UserName", modelLogin.UserName),
                new KeyValuePair <string, object>("UserPassword", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(modelLogin.Password))),
                new KeyValuePair <string, object>("IPAddress", System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.Where(item => item.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).FirstOrDefault().ToString())
            };

            dt_1 = clsDAC.Read_DT_Procedure("sp_Login", lstData);

            if (dt_1 == null || dt_1.Rows.Count == 0)
            {
                modelLogin.LoginStatus     = "Login Failed: Unable to access";
                modelLogin.LoginStatusCode = "0";
            }
            else if (dt_1 != null && dt_1.Rows.Count > 0)
            {
                modelLogin.userID          = Convert.ToInt32(dt_1.Rows[0]["UserID"]);
                modelLogin.LoginStatusCode = Convert.ToString(dt_1.Rows[0]["LoginStatusCode"]);
                modelLogin.LoginStatus     = Convert.ToString(dt_1.Rows[0]["LoginStatus"]);
                modelLogin.IPAddress       = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.Where(item => item.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).FirstOrDefault().ToString();
                modelLogin.LoginTimeStamp  = Convert.ToDateTime(dt_1.Rows[0]["LoginTimeStamp"]);
            }

            if (modelLogin.LoginStatusCode != "1")
            {
                lstModels.Add(modelLogin);
                lstModels.Add(modelSubjectsList);
                return(View("Index", "~/Views/Shared/_IndexPageLayout.cshtml", lstModels));
            }

            Session["LoginID"]        = Convert.ToInt32(dt_1.Rows[0]["LoginID"]);
            Session["UserID"]         = modelLogin.userID;
            Session["UserName"]       = modelLogin.UserName;
            Session["UserType"]       = Convert.ToString(dt_1.Rows[0]["UserType"]);
            Session["UserFirstName"]  = Convert.ToString(dt_1.Rows[0]["FirstName"]);
            Session["UserLastName"]   = Convert.ToString(dt_1.Rows[0]["LastName"]);
            Session["LoginTimeStamp"] = Convert.ToDateTime(modelLogin.LoginTimeStamp);
            Session["StudentID"]      = Convert.ToString(dt_1.Rows[0]["StudentID"]) == "" ? 0 : Convert.ToInt32(dt_1.Rows[0]["StudentID"]);

            if (Convert.ToString(dt_1.Rows[0]["UserType"]) == "Admin")
            {
                Response.Redirect("~/Admin/Index");
            }
            else if (Convert.ToString(dt_1.Rows[0]["UserType"]) == "User")
            {
                Response.Redirect("~/User/Index");
            }

            lstModels.Add(modelLogin);
            lstModels.Add(modelSubjectsList);
            return(View("Index", "~/Views/Shared/_IndexPageLayout.cshtml", lstModels));
        }
        public ActionResult ChapterContents(FormCollection frmCollection, int ID = 0, int page = 1)
        {
            verifySessionforAdmin();
            var ImageFileName = ""; //using this field to save variant value
            var VideoFileName = "";
            var PdfFileName   = "";

            var ImageFilePath = "";
            var VideoFilePath = "";
            var PdfFilePath   = "";
            var isfree        = false;
            var PaperYear     = "";



            MSSQL_DAC clsDAC = null;

            clsDAC = new MSSQL_DAC();
            List <string> FilesAlreadyLoaded = new List <string>();
            int           SubjectChapterID   = 0;

            isfree = Convert.ToBoolean(frmCollection["Isfree"]);
            Int32.TryParse(Convert.ToString(frmCollection["SubjectChapterID"]), out SubjectChapterID);

            if (!string.IsNullOrEmpty(frmCollection["PaperYear"]))
            {
                PaperYear = Convert.ToString(frmCollection["PaperYear"]);
            }
            if (!string.IsNullOrEmpty(frmCollection["QuestionDiagram"]))
            {
                ImageFileName = Convert.ToString(frmCollection["QuestionDiagram"]);
            }
            if (Request.Files.Count > 0)
            {
                for (int updFile = 0; updFile < Request.Files.Count; updFile++)
                {
                    //string ContentFileName = Convert.ToString(dt_1.Rows[0]["ContentFileName"]);
                    var supportedFile             = false;
                    HttpPostedFileBase postedFile = Request.Files[updFile];
                    var         fileName          = postedFile.FileName;
                    var         fileExtension     = System.IO.Path.GetExtension(fileName).ToLower();
                    System.Guid Guid    = System.Guid.NewGuid();
                    var         guidStr = Guid.ToString() + fileExtension;

                    if (fileExtension == ".mp4")
                    {
                        supportedFile = true;
                        VideoFileName = fileName;
                        VideoFilePath = guidStr;
                    }
                    //else if (fileExtension == ".png" || fileExtension == ".jpg" || fileExtension == ".jpeg")
                    //{
                    //    supportedFile = true;
                    //    ImageFileName = fileName;
                    //    ImageFilePath = guidStr;
                    //}
                    else if (fileExtension == ".pdf")
                    {
                        supportedFile = true;
                        PdfFileName   = fileName;
                        PdfFilePath   = guidStr;
                    }

                    if (supportedFile)
                    {
                        fileName = guidStr; //System.IO.Path.GetFileName(fileName);
                        System.IO.MemoryStream mem = new System.IO.MemoryStream();
                        var path = System.IO.Path.Combine(Server.MapPath("~/ContentStorage/ChaptersContents/"), fileName);
                        //    postedFile.InputStream.CopyTo(mem);
                        //    System.IO.File.WriteAllBytes(System.IO.Path.Combine(Server.MapPath("~/ContentStorage/ChaptersContents/"), fileName), mem.ToArray());
                        //
                        postedFile.SaveAs(path);
                    }
                }
            }


            {
                List <KeyValuePair <string, object> > lstData = new List <KeyValuePair <string, object> >()
                {
                    new KeyValuePair <string, object>("SubjectsChaptersID", SubjectChapterID),
                    new KeyValuePair <string, object>("Url", frmCollection["youTubeUrl"]),
                    new KeyValuePair <string, object>("CreatedBy", Session["UserID"]),
                    new KeyValuePair <string, object>("QuestionText", frmCollection["questionText"]),
                    new KeyValuePair <string, object>("ImageFileName", ImageFileName),
                    new KeyValuePair <string, object>("VideoFileName", VideoFileName),
                    new KeyValuePair <string, object>("PaperYear", PaperYear),
                    new KeyValuePair <string, object>("PdfDocFile", PdfFileName),
                    new KeyValuePair <string, object>("ImageFilePath", ImageFilePath),
                    new KeyValuePair <string, object>("VideoFilePath", VideoFilePath),
                    new KeyValuePair <string, object>("PdfDocFilePath", PdfFilePath),
                    new KeyValuePair <string, object>("Isfree", isfree),
                };

                DataTable dt_1 = clsDAC.Read_DT_Procedure("sp_SaveChaptersQuestions", lstData);
                ViewBag.Error = clsDAC.Error_Message;
            }
            //if (Request.Files.Count > 0)
            //{
            //    for (int updFile = 0; updFile < Request.Files.Count; updFile++)
            //    {
            //        List<KeyValuePair<string, object>> lstData = new List<KeyValuePair<string, object>>()
            //        {
            //        new KeyValuePair<string,object>("SubjectsChaptersID",SubjectChapterID),
            //        new KeyValuePair<string,object>("OriginalFileName",Request.Files[updFile].FileName),
            //        new KeyValuePair<string,object>("CreatedBy",Session["UserID"])
            //        };

            //        DataTable dt_1 = clsDAC.Read_DT_Procedure("sp_SaveChaptersContents", lstData);
            //        ViewBag.Error = clsDAC.Error_Message;

            //        if (dt_1 != null || dt_1.Rows.Count > 0)
            //        {
            //            if (Convert.ToBoolean(dt_1.Rows[0]["IsAlreadyLoaded"]))
            //            {
            //                FilesAlreadyLoaded.Add(Convert.ToString(dt_1.Rows[0]["OriginalFileName"]));
            //            }
            //            else
            //            {
            //                string ContentFileName = Convert.ToString(dt_1.Rows[0]["ContentFileName"]);
            //                HttpPostedFileBase postedFile = Request.Files[updFile];
            //                System.IO.MemoryStream mem = new System.IO.MemoryStream();
            //                postedFile.InputStream.CopyTo(mem);
            //                System.IO.File.WriteAllBytes(Server.MapPath("/ContentStorage/ChaptersContents/") + ContentFileName, mem.ToArray());
            //            }
            //        }
            //    }
            //}


            List <object> lstRet = new List <object>();

            lstRet = new SubjectsController().getChapterContentsByID(SubjectChapterID);
            string ChapterName = "";
            string SubjectName = "";

            if (lstRet.Count() > 0)
            {
                var ChapterContentBasic = lstRet.FirstOrDefault();
                ChapterName = Convert.ToString(ChapterContentBasic.GetType().GetProperty("ChapterName").GetValue(ChapterContentBasic));
                SubjectName = Convert.ToString(ChapterContentBasic.GetType().GetProperty("SubjectName").GetValue(ChapterContentBasic));
            }

            ViewBag.SubjectsChaptersID  = SubjectChapterID;
            ViewBag.ChapterName         = ChapterName;
            ViewBag.SubjectName         = SubjectName;
            ViewBag.ChapterContentsList = lstRet;
            ViewBag.FilesAlreadyLoaded  = FilesAlreadyLoaded;
            ViewBag.SubjectsChaptersID  = ID;

            //////////Response.Redirect(string.Format("~/Chapters/ChapterContents?ID={0}", SubjectChapterID));
            ////RedirectToAction(string.Format("ChapterContents?ID={0}", SubjectChapterID));
            //   return View(SubjectChapterID);
            return(RedirectToAction("ChapterContents", new { ID = SubjectChapterID }));
        }
        public ActionResult ChapterQuestions(int Sub, int questionYearId, string variant, bool scfp = false)
        {
            ChaptersViewModel vm            = new ChaptersViewModel();
            PayPalManager     payPalManager = new PayPalManager();
            int subjecttype;

            if (scfp == false)
            {
                if (TempData["paymentTransactionId"] != null)
                {
                    SubjectsController sc = new SubjectsController();
                    sc.DeleteInvoiceFromPaymentQuestion(Convert.ToString(TempData["paymentTransactionId"]));
                    payPalManager.DeletePayPalInvoice(Convert.ToString(TempData["paymentTransactionId"]));

                    ViewBag.paymentTransactionId     = null;
                    TempData["paymentTransactionId"] = null;
                }
                else if (TempData["paymentTransactionId"] == null)
                {
                    ViewBag.paymentTransactionId     = null;
                    TempData["paymentTransactionId"] = null;
                }
            }

            if (TempData["paymentTransactionId"] != null)
            {
                var invoice = payPalManager.GetPayPalInvoiceByGUID(Convert.ToString(TempData["paymentTransactionId"]));
                if (invoice != null)
                {
                    if (invoice.QuestionID != Sub)
                    {
                        ViewBag.paymentTransactionId = null;
                    }
                    else if (invoice.QuestionID == Sub && !string.IsNullOrEmpty(variant))
                    {
                        List <QuestionPayment> lstQuestion = new SubjectsController().getQuesionsFromPaymentQuestion_BySubjectsIDAndTransactionAndVarient(Sub, Convert.ToString(TempData["paymentTransactionId"]), variant);
                        if (lstQuestion.Count > 0)
                        {
                            if (lstQuestion.Select(x => x.create_date == DateTime.Now.Date).FirstOrDefault())
                            {
                                ViewBag.paymentTransactionId = TempData["paymentTransactionId"];
                                TempData.Keep("paymentTransactionId");

                                //try
                                //{
                                //    MailMessage msgs = new MailMessage();
                                //    msgs.To.Add("*****@*****.**");
                                //    MailAddress address = new MailAddress("*****@*****.**");
                                //    msgs.From = address;
                                //    msgs.Subject = "USer Redirect to Payment";
                                //    string htmlBody = "Sending This email When user click on Payment Button ";
                                //    msgs.Body = htmlBody;
                                //    msgs.IsBodyHtml = true;
                                //    SmtpClient client = new SmtpClient();
                                //    client.Host = "relay-hosting.secureserver.net";
                                //    client.Port = 25;
                                //    client.UseDefaultCredentials = false;
                                //    client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "asjad001$");
                                //    //Send the msgs
                                //    client.Send(msgs);

                                //}
                                //catch (Exception ex) { }
                            }
                            else
                            {
                                ViewBag.paymentTransactionId = null;
                            }
                        }
                        else
                        {
                            ViewBag.paymentTransactionId = null;
                        }
                    }
                    else
                    {
                        List <QuestionPayment> lstQuestion = new SubjectsController().getQuesionsFromPaymentQuestion_BySubjectsIDAndTransaction(Sub, Convert.ToString(TempData["paymentTransactionId"]));
                        if (lstQuestion.Count > 0)
                        {
                            if (lstQuestion.Select(x => x.create_date == DateTime.Now.Date).FirstOrDefault())
                            {
                                ViewBag.paymentTransactionId = TempData["paymentTransactionId"];
                                TempData.Keep("paymentTransactionId");
                                //try
                                //{
                                //    MailMessage msgs = new MailMessage();
                                //    msgs.To.Add("*****@*****.**");
                                //    MailAddress address = new MailAddress("*****@*****.**");
                                //    msgs.From = address;
                                //    msgs.Subject = "USer Redirect to Payment";
                                //    string htmlBody = "Sending This email When user click on Payment Button ";
                                //    msgs.Body = htmlBody;
                                //    msgs.IsBodyHtml = true;
                                //    SmtpClient client = new SmtpClient();
                                //    client.Host = "relay-hosting.secureserver.net";
                                //    client.Port = 25;
                                //    client.UseDefaultCredentials = false;
                                //    client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "asjad001$");
                                //    //Send the msgs
                                //    client.Send(msgs);

                                //}
                                //catch (Exception ex) { }
                            }
                            else
                            {
                                ViewBag.paymentTransactionId = null;
                            }
                        }
                        else
                        {
                            ViewBag.paymentTransactionId = null;
                        }
                    }
                }
                else
                {
                    ViewBag.paymentTransactionId = null;
                }
            }
            else
            {
                ViewBag.paymentTransactionId = null;
            }



            List <SubjectChapters> lstRet  = new SubjectsController().getChaptersExerciseBySubjectsID(Sub);
            List <Questions>       lstRet1 = new SubjectsController().getChaptersQuesionsBySubjectsID(Sub);
            var variants1 = lstRet1.Where(x => !string.IsNullOrWhiteSpace(x.ImageFileName)).Select(x => x.ImageFileName).Distinct().ToList();

            subjecttype             = lstRet.Select(x => x.SubjectType).FirstOrDefault();
            ViewBag.subjecttype     = subjecttype;
            ViewBag.selectedVariant = null;

            // var type = lstsubjects.Select(x=>x.SubjectID) lstRet1.Select(x => x.SubjectsChaptersID).FirstOrDefault();
            vm.Variants = GetSelectListItems(variants1);
            var questionYear = lstRet1.Where(x => x.QuestionID == questionYearId).FirstOrDefault()?.PaperYear;

            //var questionYear = lstRet1.FirstOrDefault()?.PaperYear;
            ViewBag.questionYearId = questionYearId;


            //var variatnEndwith2;
            //foreach
            if (subjecttype == 1 || subjecttype == 4 || subjecttype == 5 || subjecttype == 8)
            {
                if (!string.IsNullOrEmpty(variant))
                {
                    lstRet1 = lstRet1.Where(x => x.ImageFileName == variant).ToList();
                    ViewBag.selectedVariant = variant;
                }
                else
                {
                    var variants2 = variants1.Where(x => x.EndsWith("2")).FirstOrDefault();
                    lstRet1 = lstRet1.Where(x => x.ImageFileName == variants2).ToList();
                    ViewBag.selectedVariant = variants2;
                }
            }



            vm.SubjectChapters = lstRet;
            vm.Questions       = lstRet1.Where(x => x.PaperYear == questionYear).ToList();

            return(View(vm));
        }