public ActionResult Dashboard() { // check if logged in if (Session["parent"] == null) { return(View("Login")); } ParentModel parent = Session["parent"] as ParentModel; parent.Children = parentDAL.GetChildren(parent.Parent_ID); // add mascots to child list foreach (ChildModel child in parent.Children) { child.Mascot = mascotDAL.GetMascot(child); if (activityDAL.IdExists(child.Child_Id)) { child.TotalSteps = activityDAL.GetSteps(child.Child_Id); child.TotalMinutes = activityDAL.GetMinutes(child.Child_Id); } else { child.TotalSteps = 0; child.TotalMinutes = 0; } } return(View("Dashboard", parent)); }
public ActionResult AddCarrot(string userName) { childDAL.AddCarrot(userName); ChildModel child = childDAL.GetChild(userName); child.Mascot = mascotDAL.GetMascot(child); Session["child"] = child; return(null); }
public ActionResult Login(ChildLoginModel model) { // validation redirect if (!ModelState.IsValid) { return(View("Login", model)); } ChildModel child = childDAL.GetChild(model.UserName); HashProvider hash = new HashProvider(); // check if child exists and passwords match if (child == null || !hash.VerifyPasswordMatch(child.Password, model.Password, child.Salt)) { ModelState.AddModelError("invalid-credentials", "Invalid email password combination"); return(View("Login", model)); } // check if child has time remaining if (child.Seconds <= 0) { ModelState.AddModelError("no-time-remaining", "You do not have any time remaining. You need more steps to earn more time."); return(View("Login", model)); } child.Mascot = mascotDAL.GetMascot(child); Session["child"] = child; // check if child needs to create mascot if (child.Mascot == null) { return(RedirectToAction("ChooseMascot")); } return(RedirectToAction("Dashboard")); }