public IActionResult jslesson3p3() { CodePyramidContext context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext; int progressSuccess = context.InsertLessonCompletion("Javascript Lesson 3", Request.Cookies["currentUser"]); return(View()); }
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()); }
public IActionResult Courses() { ViewData["Message"] = "Courses at CodePyramid:"; CodePyramidContext context = HttpContext.RequestServices.GetService(typeof(CodePyramidContext)) as CodePyramidContext; var list = context.GetAllCourses(); return(View(list)); }
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")); }
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)); }
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()); } }
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 })); }