Beispiel #1
0
        public ActionResult Login(Member credentials)
        {
            if (credentials.DisplayName == null || credentials.Password == null)
            {
                ModelState.AddModelError("login-error", "null name or password");
                return(View("Login", credentials));
            }

            bool nameExists = memberSQL.CheckForNameCase(credentials.DisplayName);

            if (!nameExists)
            {
                ModelState.AddModelError("login-error", "name not found");
                return(View("Login", credentials));
            }

            Member member = memberSQL.GetMemberByName(credentials.DisplayName);

            if (member.Password != credentials.Password)
            {
                ModelState.AddModelError("login-error", "incorrect password");
                return(View("Login", credentials));
            }

            Session["member"] = member;
            TempData["msg"]   = "login";
            return(RedirectToAction("Index"));
        }
        public ActionResult ChangeName(Member member)
        {
            if (memberSQL.CheckForNameCase(member.DisplayName))
            {
                ModelState.AddModelError("changename-error", "That name already exists");
                return(RedirectToAction("OwnInfo"));
            }
            memberSQL.ChangeName(member.DisplayName, member.ID);
            Session["member"] = memberSQL.GetMemberByID(member.ID);
            TempData["msg"]   = "name_changed";

            return(RedirectToAction("OwnInfo"));
        }