コード例 #1
0
        public ActionResult Register(MemberRegister member)
        {
            // Formulaire invalide
            if (!ModelState.IsValid)
            {
                // Retour au formulaire !
                return(View(member));
            }

            // Check si l'email ou le pseudo exsite
            if (MemberService.Instance.CheckAccountExists(member))
            {
                // Retour au formulaire !
                ModelState.AddModelError("Account", "Le compte existe déjà");
                return(View(member));
            }

            // Save in DB
            MemberProfil profil = MemberService.Instance.InsertMember(member);

            // Ajout en Session
            SessionHelper.Member = profil;

            // Redirection vers la page Home
            return(RedirectToAction("Index", "Home"));
        }
コード例 #2
0
        public ActionResult Login(MemberLogin member)
        {
            if (!ModelState.IsValid)
            {
                return(View(member));
            }

            MemberProfil profil = MemberService.Instance.GetMember(member);

            if (profil == null)
            {
                ModelState.AddModelError("Account", "Bad credential");
                return(View(member));
            }

            // Sauvegarde du Login dans la Session
            SessionHelper.Member = profil;

            // Redirection vers la page Home
            return(RedirectToAction("Index", "Home"));
        }