Exemple #1
0
        public async Task <IActionResult> PostAsync(users value)
        {
            userb = new usersAuth();

            usersWithROL userRol = new usersWithROL();

            userRol.email  = value.email;
            userRol.userID = "idUser";
            userRol.rol    = value.rol;


            var result = userb.registerUserRol(userRol);

            if (!result.IsSuccessStatusCode)
            {
                Console.Write("Se presento error");
                return(BadRequest(result));
            }


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

            userName nameID = null;

            nameID = JsonConvert.DeserializeObject <userName>(jsonDB.ToString(), new JsonSerializerSettings()
            {
                MissingMemberHandling = MissingMemberHandling.Ignore
            });


            value.displayName = nameID.name;
            var response = userb.registerUser(value);
            var json     = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                Console.Write("Se presento error");
                return(BadRequest(json));
            }
            else
            {
                userRegisterFirebase claims = null;

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

                claims.rol  = value.rol;
                claims.rute = "0";

                Console.Write("Success");
                return(Ok(claims));
            }
        }
        public IActionResult Post(users value)
        {
            userb = new usersAuth();
            var response = userb.registerUser(value);
            var json     = response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                Console.Write("Se presento error");
                return(BadRequest(json.Result));
            }
            else
            {
                Console.Write("Success");
                return(Ok(json.Result));
            }
        }