Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        // Set this before calling into the realtime database.
        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://gabudnus.firebaseio.com/");
        DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

        string email = PlayerPrefs.GetString("email");
        string date  = System.DateTime.Now.ToLongDateString();
        string time  = System.DateTime.Now.ToLongTimeString();
        int    skor  = PlayerPrefs.GetInt("skor");
        int    order = -1 * skor;

        userFirebase user = new userFirebase(email, date, time, skor, order);
        string       json = JsonUtility.ToJson(user);

        reference.Child("User").Push().SetRawJsonValueAsync(json);
    }
Exemplo n.º 2
0
        public async Task <IActionResult> LoginAsync(userLogin user)
        {
            userb = new usersAuth();
            var response = userb.loginAuth(user);

            var json = await response.Content.ReadAsStringAsync();

            userFirebase claims = null;

            claims = JsonConvert.DeserializeObject <userFirebase>(json.ToString(), new JsonSerializerSettings()
            {
                MissingMemberHandling = MissingMemberHandling.Ignore
            });


            var result = userb.GetrRolxID(claims.displayName);

            var jsonRol = await result.Content.ReadAsStringAsync();

            usersWithROL rol = null;

            rol = JsonConvert.DeserializeObject <usersWithROL>(jsonRol.ToString(), new JsonSerializerSettings()
            {
                MissingMemberHandling = MissingMemberHandling.Ignore
            });

            claims.rol  = rol.rol;
            claims.rute = rol.rute;


            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine("Se presento un Error");
                return(BadRequest(claims));
            }
            else
            {
                Console.WriteLine("Success");
                return(Ok(claims));
            }
        }