コード例 #1
0
        public IActionResult jslesson3p3()
        {
            CodePyramidContext context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext;
            int progressSuccess        = context.InsertLessonCompletion("Javascript Lesson 3", Request.Cookies["currentUser"]);

            return(View());
        }
コード例 #2
0
        public IActionResult htmlcsslesson1p4() //QUIZ
        {
            CodePyramidContext context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext;
            int progressSuccess        = context.InsertLessonCompletion("HTML/CSS Lesson 1", Request.Cookies["currentUser"]);

            return(View());
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: iarslan/CodePyramid
        public IActionResult Courses()
        {
            ViewData["Message"] = "Courses at CodePyramid:";
            CodePyramidContext context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext;

            var list = context.GetAllCourses();


            return(View(list));
        }
コード例 #4
0
        public ActionResult Register(RegisterViewModel model)
        {
            CodePyramidContext context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext;
            int rowsAffected           = context.RegisterUser(model);

            if (rowsAffected == 0)
            {
                return(RedirectToAction("RegistrationFailure"));
            }
            return(RedirectToAction("RegistrationSuccess"));
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: iarslan/CodePyramid
        public ActionResult MyAccount()
        {
            String uname = Request.Cookies["currentUser"];

            if (uname == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            CodePyramidContext             context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext;
            ProgressAndAssessmentViewModel paavm   = context.FetchProgressResults(uname);

            paavm.CompletedLessons.Sort();
            return(View(paavm));
        }
コード例 #6
0
        public IActionResult assessmentSubmission(String percentScore, String assessmentName)
        {
            CodePyramidContext context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext;
            int quizSuccess            = context.InsertAssessmentScore(assessmentName, Request.Cookies["currentUser"], Convert.ToInt16(percentScore));

            if (quizSuccess == 0)
            {
                TempData["Result"] = String.Format("Thanks for submitting! You scored " + percentScore + "%. Nice work!");
                return(View());
            }
            else
            {
                TempData["Result"] = "DISASTER! Your score was: " + percentScore + "%, but the error code was: " + quizSuccess;
                return(View());
            }
        }
コード例 #7
0
        public ActionResult Login(LoginViewModel model)
        {
            CodePyramidContext context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext;
            string             name    = context.GetLogonInfo(model);

            if (string.IsNullOrEmpty(name))
            {
                return(RedirectToAction("LoginFailure"));
            }

            //Create a username cookie with a 1 day duration
            CookieOptions option = new CookieOptions
            {
                Expires = DateTime.Now.AddDays(1)
            };

            Response.Cookies.Append("currentUser", model.Username, option);

            return(RedirectToAction("LoginSuccess", "Account", new { model = model.Username }));
        }