public string Login(LoginViewModel viewModel)
        {
            if (string.IsNullOrEmpty(viewModel.email))
            {
                return(JsonConvert.
                       SerializeObject(new ResultViewModel(
                                           "Email không được để trống",
                                           "Đã xảy ra lỗi trong quá trình đăng nhập")));
            }

            if (string.IsNullOrEmpty(viewModel.password))
            {
                return(JsonConvert.
                       SerializeObject(new ResultViewModel(
                                           "Password không được để trống",
                                           "Đã xảy ra lỗi trong quá trình đăng nhập")));
            }

            try
            {
                var addr = new System.Net.Mail.MailAddress(viewModel.email);
                if (addr.Address != viewModel.email)
                {
                    throw new System.Exception();
                }
            }
            catch
            {
                return(JsonConvert.
                       SerializeObject(new ResultViewModel(
                                           "Email không hợp lệ",
                                           "Đã xảy ra lỗi trong quá trình đăng nhập")));
            }

            var TaiKhoan = Authentication_DAO.layTaiKhoan(viewModel.email, viewModel.password);

            if (TaiKhoan == null)
            {
                return(JsonConvert.
                       SerializeObject(new ResultViewModel(
                                           "Nhập sai tên đăng nhập hoặc mật khẩu",
                                           "Đã xảy ra lỗi trong quá trình đăng nhập")));
            }
            else if (TaiKhoan.TrangThai == false)
            {
                return(JsonConvert.
                       SerializeObject(new ResultViewModel(
                                           "Tài khoản này đã bị vô hiệu hóa",
                                           "Đã xảy ra lỗi trong quá trình đăng nhập")));
            }
            else
            {
                Session.Add("User", TaiKhoan);
            }

            return("");
        }
        // POST: api/User
        public string Post(createUserViewModel viewModel)
        {
            var Session = HttpContext.Current.Session;

            if (!Session.isAdminSession())
            {
                return("");
            }

            string Error = ValidateViewModel(viewModel);

            if (Error == "")
            {
                if (string.IsNullOrEmpty(viewModel.MatKhau))
                {
                    return(JsonConvert.
                           SerializeObject(new ResultViewModel(
                                               "Mật khẩu không được để trống",
                                               "Đã xảy ra lỗi trong quá trình tạo tài khoản")));
                }

                if (!Helper.KiemTraHopLeMatKhau(viewModel.MatKhau))
                {
                    return(JsonConvert.
                           SerializeObject(new ResultViewModel(
                                               "Mật khẩu phải có kí tự viết hoa, tối thiểu 8 kí tự",
                                               "Đã xảy ra lỗi trong quá trình tạo tài khoản")));
                }

                if (string.IsNullOrEmpty(viewModel.MatKhau))
                {
                    return(JsonConvert.
                           SerializeObject(new ResultViewModel(
                                               "Mật khẩu nhập lại không được để trống",
                                               "Đã xảy ra lỗi trong quá trình tạo tài khoản")));
                }

                if (!Authentication_DAO.TaoTaiKhoan(viewModel))
                {
                    return(JsonConvert.
                           SerializeObject(new ResultViewModel(
                                               "Email của tài khoản này đã tồn tại rồi",
                                               "Đã xảy ra lỗi trong quá trình tạo tài khoản")));
                }
            }

            return(Error);
        }