Exemple #1
0
        public ActionResult ConfirmEmail(AccountObject objAccount)
        {
            //objAccount.Gender = Request["Gender"].Equals("male"); // Lấy giới tính string => bool

            // Check email empty string + không trùng trong db
            if (string.IsNullOrEmpty(objAccount.Email) && AccountBCL.CheckEmail(objAccount.Email))
            {
                // Nếu email trống hoặc đã tồn tại, tải lại trang và yêu cầu kiểm tra lại
                ViewBag.ErrorEmail = true; // Mình thích thì mình báo lỗi thôi
                return(View(objAccount));
            }

            // Email đã hợp lệ
            // Cho phép thêm tài khoản vào csdl
            objAccount.AccountID = Guid.NewGuid();
            //objAccount.RoleId = 3; // tk thường
            //objAccount.ModifiedTime = DateTime.Now;
            new AccountBCL().Insert(objAccount);

            // Tạo session
            Session.Add(Comomconstants.USER_SESSION, objAccount);

            // Tải lại trang
            return(RedirectToAction("Index", "Home"));
        }