public async Task <IActionResult> SetRoles([FromBody] List <Authentication.Core.nguoidung_role> data)
        {
            try
            {
                using (var db = new TM.Core.Connection.Oracle())
                {
                    var nd = db.Connection.getUserFromToken(TM.Core.HttpContext.Header("Authorization"));
                    if (nd == null)
                    {
                        return(Json(new { msg = TM.Core.Common.Message.error_token.ToString() }));
                    }
                    var nguoidung = await db.Connection.GetAllAsync <Authentication.Core.nguoidung>();

                    var index = 0;
                    var qry   = "BEGIN ";
                    foreach (Authentication.Core.nguoidung_role item in data)
                    {
                        // var _data = await db.Connection.GetAsync<Authentication.Core.nguoidung>(item.nguoidung_id);
                        if (nguoidung.Any(x => x.nguoidung_id == item.nguoidung_id))
                        {
                            qry += $"update nguoidung set roles_id='{item.roles_id}' where nguoidung_id={item.nguoidung_id};\r\n";
                            index++;
                        }
                        else
                        {
                            var matkhau = "vnptbkn@123";
                            var tmp     = new Authentication.Core.nguoidung();
                            tmp.nguoidung_id = item.nguoidung_id;
                            tmp.salt         = Guid.NewGuid().ToString("N");
                            tmp.matkhau      = TM.Core.Encrypt.MD5.CryptoMD5TM(matkhau + tmp.salt);
                            tmp.updated_by   = nd.ma_nd;
                            tmp.updated_at   = DateTime.Now;
                            tmp.roles_id     = item.roles_id;
                            await db.Connection.InsertOraAsync(tmp);
                        }
                    }
                    qry += "END;";
                    if (index > 0)
                    {
                        await db.Connection.QueryAsync(qry);

                        await db.Connection.QueryAsync("COMMIT");
                    }
                    return(Json(new { msg = TM.Core.Common.Message.success.ToString() }));
                }
            }
            catch (System.Exception) { return(Json(new { msg = TM.Core.Common.Message.danger.ToString() })); }
            finally { }
        }
        public async Task <IActionResult> ResetPassword(int id)
        {
            try
            {
                using (var db = new TM.Core.Connection.Oracle())
                {
                    var nd = db.Connection.getUserFromToken(TM.Core.HttpContext.Header("Authorization"));
                    if (nd == null)
                    {
                        return(Json(new { msg = TM.Core.Common.Message.error_token.ToString() }));
                    }
                    var matkhau = "vnptbkn@123";
                    var _data   = await db.Connection.GetAsync <Authentication.Core.nguoidung>(id);

                    if (_data != null)
                    {
                        // _data.app_key = data.app_key;
                        _data.matkhau        = TM.Core.Encrypt.MD5.CryptoMD5TM(matkhau + _data.salt);
                        _data.change_pass_by = nd.ma_nd;
                        _data.change_pass_at = DateTime.Now;
                        await db.Connection.UpdateAsync(_data);
                    }
                    else
                    {
                        var tmp = new Authentication.Core.nguoidung();
                        tmp.nguoidung_id   = id;
                        tmp.salt           = Guid.NewGuid().ToString("N");
                        tmp.matkhau        = TM.Core.Encrypt.MD5.CryptoMD5TM(matkhau + tmp.salt);
                        tmp.change_pass_by = nd.ma_nd;
                        tmp.change_pass_at = DateTime.Now;
                        await db.Connection.InsertOraAsync(tmp);
                    }
                    return(Json(new { data = matkhau, msg = TM.Core.Common.Message.success.ToString() }));
                }
            }
            catch (System.Exception) { return(Json(new { msg = TM.Core.Common.Message.danger.ToString() })); }
            finally { }
        }