Beispiel #1
0
        public ActionResult TakeTest(ExamenDataModel examen)
        {
            try
            {
                if (Session["no"] == null)
                {
                    i = 0;
                }
                else
                {
                    i = Convert.ToInt32(Session["no"]);
                }
                ExamenBL bl        = new ExamenBL();
                string   testmodel = Session["modl"].ToString();
                //string testmodel = "Aptitude";
                List <ExamenDataModel> pQuestions    = GetAllQuestionsFromBL(testmodel);
                ExamenDataModel        pageQuestions = new ExamenDataModel();

                pageQuestions.Sno       = pQuestions[i].Sno;
                pageQuestions.Questions = pQuestions[i].Questions;
                pageQuestions.Option1   = pQuestions[i].Option1;
                pageQuestions.Option2   = pQuestions[i].Option2;
                pageQuestions.Option3   = pQuestions[i].Option3;
                pageQuestions.Option4   = pQuestions[i].Option4;
                pageQuestions.Answers   = pQuestions[i].Answers;
                return(View(pageQuestions));
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Please Select an answer";
            }
            return(View());
        }
        public ActionResult Home(string submitbutton)
        {
            ExamenBL bl = new ExamenBL();

            if (submitbutton == "Register for Exam")
            {
                return(RedirectToAction("ExamRegister", "HomePageExamen"));
            }
            else
            if (submitbutton == "Take Test")
            {
                return(RedirectToAction("InstructionPage", "HomePageExamen"));
            }
            else if (submitbutton == "View Profile")
            {
                TempData["un"] = ViewBag.WelcomeMsg;
                return(RedirectToAction("ViewProfile", "HomePageExamen"));
            }
            else if (submitbutton == "Log Out")
            {
                Session["un"] = null;
                return(RedirectToAction("Index", "WelcomePage"));
            }


            return(View());
        }
Beispiel #3
0
        public ActionResult ExamRegister(ExamenDataModel dataModel)
        {
            //if (TempData["un"] == null)
            //{
            //    return RedirectToAction("LogIn", "WelcomePage");
            //}
            //else if (TempData["un"] != null)
            //{
            //    ViewBag.WelcomeMsg = TempData["un"].ToString();
            //}
            ExamenBL bl = new ExamenBL();

            dataModel = new ExamenDataModel();
            List <string> examens = bl.GetAllTestModels();

            dataModel.Testmodels = new SelectList(examens.ToList());
            return(View(dataModel));
        }
        public ActionResult LogIn(ExamenDataModel examen, string submitbutton)
        {
            try
            {
                ExamenBL bl       = new ExamenBL();
                string   Username = examen.Username;
                string   Password = examen.Password;
                if (submitbutton == "LogIn")
                {
                    if (string.IsNullOrEmpty(examen.Username))
                    {
                        ModelState.AddModelError("Username", "Username is required");
                    }
                    else
                    {
                        if ((bl.UserValidation(Username, Password)))
                        {
                            Session.Add("un", Username);
                            return(RedirectToAction("Home", "WelcomePage"));
                        }
                        else
                        {
                            ViewBag.Message = "Invalid Username or Password";
                        }
                    }
                }
                else if (submitbutton == "Cancel")
                {
                    return(RedirectToAction("Index", "WelcomePage"));
                }
            }
            catch (SqlException se)
            {
                ViewBag.ErrorMessage = "Invalid Username or Password..";
            }


            return(View());
        }
        public ActionResult Register(ExamenDataModel dataModel, string submitButton)
        {
            try
            {
                ExamenBL    bl          = new ExamenBL();
                ExamenStack examenStack = new ExamenStack();

                examenStack.Phone    = dataModel.Phone;
                examenStack.Email    = dataModel.Email;
                examenStack.Username = dataModel.Username;
                examenStack.Password = dataModel.Password;

                examenStack.Name = dataModel.Name;
                if (submitButton == "Submit")
                {
                    if (bl.InsertIntoCandidates(examenStack))
                    {
                        ViewBag.Message = "Registered Successfully";
                        return(RedirectToAction("RegisterSuccessView", "WelcomePage"));
                    }
                    else
                    {
                        return(ViewBag.Message = "Registration Failed..");
                    }
                }
                else
                if (submitButton == "Cancel")
                {
                    return(RedirectToAction("Index", "WelcomePage"));
                }
            }
            catch (SqlException se)
            {
                ViewBag.ErrorMessage = "Invalid Username or Password..";
            }

            return(View());
        }
Beispiel #6
0
        private List <ExamenDataModel> GetAllQuestionsFromBL(string testmodel)
        {
            ExamenBL bl = new ExamenBL();

            List <ExamenDataModel> dataModels = new List <ExamenDataModel>();
            ExamenDataModel        dataModel  = null;
            List <ExamenStack>     examen     = bl.GetAllQuestionsandAnswers(testmodel);

            foreach (ExamenStack item in examen)
            {
                dataModel     = new ExamenDataModel();
                dataModel.Sno = item.Sno;

                dataModel.Questions = item.Questions;
                dataModel.Option1   = item.Option1;
                dataModel.Option2   = item.Option2;
                dataModel.Option3   = item.Option3;
                dataModel.Option4   = item.Option4;
                dataModel.Answers   = item.Answers;
                dataModels.Add(dataModel);
            }
            return(dataModels);
        }