private async void Click_Login(object sender, EventArgs e) { if (String.IsNullOrEmpty(_edtEmail.Text) || String.IsNullOrEmpty(_edtPassword.Text)) { Toast.MakeText(this, "Vui lòng nhập đủ thông tin!", ToastLength.Long).Show(); } else // nhap du thong tin { //Intent intent = new Intent(this, typeof(Activity_Login_ConfirmOTP)); //StartActivity(intent); await Utilities_API.API_GetLogIn(_edtEmail.Text, _edtPassword.Text); BeanNguoiDung result = Utilities_API.RESULT_APILOGIN_BEANNGUOIDUNG; if (result != null) { if (!String.IsNullOrEmpty(result.MaNguoiDung) && !String.IsNullOrEmpty(result.TaiKhoan) && !String.IsNullOrEmpty(result.MatKhau)) // thanh cong { // kiem tra coi co confirm otp chua if (result.KichHoat == true) // da kich hoat { BeanSession session = new BeanSession(result.MaNguoiDung, result.TaiKhoan, result.MatKhau, result.HoTen, result.GioiTinh, result.NgaySinh, result.HinhAnh, result.Email, result.LoaiNguoiDung, result.KhoaNguoiDung, result.MaOtp, result.KichHoat, result.Created, result.Modified, result.CreatedBy, result.ModifiedBy); SQLiteDataHandler.BeanSession_AddSession(session); Finish(); Intent intent = new Intent(this, typeof(Activity_Home)); StartActivity(intent); } else // chua kich hoat { Finish(); Intent intent = new Intent(this, typeof(Activity_Login_ConfirmOTP)); intent.PutExtra("MaNguoiDung", result.MaNguoiDung); intent.PutExtra("TaiKhoan", result.TaiKhoan); intent.PutExtra("MatKhau", result.MatKhau); StartActivity(intent); } } else { Toast.MakeText(this, "Đăng nhập thất bại!", ToastLength.Long).Show(); } } } }
public static bool BeanSession_AddSession(BeanSession item) { try { if (File.Exists(DbFilePath)) { List <BeanSession> data = BeanSession_LoadList(); db = new SQLiteConnection(DbFilePath); db.Insert(item); return(true); } return(false); } catch (Exception e) { throw; } }
private async void SendOTP(object sender, EventArgs e) { if (_edtOTP.Text.Length == 6) { if (!String.IsNullOrEmpty(_MaNguoiDung)) { // get List Mon An await Utilities_API.API_ConfirmOTP(_MaNguoiDung, _edtOTP.Text); bool result_confirm = Utilities_API.RESULT_APIOTP_BOOL; BeanNguoiDung result = Utilities_API.RESULT_APICONFIRMOTP_BEANNGUOIDUNG; if (result_confirm == true) { Toast.MakeText(this, "Xác nhận OTP thành công!", ToastLength.Long).Show(); // Add session BeanSession session = new BeanSession(result.MaNguoiDung, result.TaiKhoan, result.MatKhau, result.HoTen, result.GioiTinh, result.NgaySinh, result.HinhAnh, result.Email, result.LoaiNguoiDung, result.KhoaNguoiDung, result.MaOtp, result.KichHoat, result.Created, result.Modified, result.CreatedBy, result.ModifiedBy); SQLiteDataHandler.BeanSession_AddSession(session); Finish(); Intent intent = new Intent(this, typeof(Activity_Home)); StartActivity(intent); } else if (result_confirm == false) { Toast.MakeText(this, "Xác nhận OTP thất bại!", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Tài khoản có lỗi xảy ra", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Mã OTP không hợp lệ", ToastLength.Long).Show(); } }