//Đăng nhập
        public async Task <Object> DangNhap(ThongTinDangNhapViewModel thongTinDangNhap)
        {
            ThanhVien thanhVien;

            using (var connection = new SqlConnection(connectionString))
            {
                var param = new DynamicParameters();
                param.Add("@TAIKHOAN", thongTinDangNhap.TaiKhoan);
                param.Add("@MATKHAU", thongTinDangNhap.MatKhau);
                thanhVien = connection.QuerySingleOrDefault <ThanhVien>("DANG_NHAP", param, commandType: CommandType.StoredProcedure);
            }

            if (thanhVien != null)
            {
                ThanhVienDangNhapViewModel thanhVienDNVM = new ThanhVienDangNhapViewModel
                {
                    MaThanhVien     = thanhVien.MaThanhVien,
                    TaiKhoan        = thanhVien.TaiKhoan,
                    HoTen           = thanhVien.HoTen,
                    Email           = thanhVien.HoTen,
                    SoDienThoai     = thanhVien.SoDienThoai,
                    MaLoaiThanhVien = thanhVien.MaLoaiThanhVien
                };

                string accessToken = GenerateToken(thanhVienDNVM);
                thanhVienDNVM.AccessToken = accessToken;

                return(thanhVienDNVM);
            }

            var response = await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Tài khoản hoặc mật khẩu không đúng!");

            return(response);
        }
        //Tạo AccessToken
        private string GenerateToken(ThanhVienDangNhapViewModel thanhVienDNVM)
        {
            var token = new System.IdentityModel.Tokens.Jwt.JwtSecurityToken(
                claims: new Claim[] {
                new Claim(ClaimTypes.Name, thanhVienDNVM.TaiKhoan),
                new Claim(ClaimTypes.Role, thanhVienDNVM.MaLoaiThanhVien.ToString()),
            },
                notBefore: new DateTimeOffset(DateTime.Now).DateTime,
                expires: new DateTimeOffset(DateTime.Now.AddMinutes(60)).DateTime,
                signingCredentials: new SigningCredentials(SIGNING_KEY, SecurityAlgorithms.HmacSha256)

                );

            return(new JwtSecurityTokenHandler().WriteToken(token));
        }