コード例 #1
0
ファイル: Coneexion.xaml.cs プロジェクト: nasrij/YourEarth
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            String url    = "http://192.168.231.51/YourEarth/login.php";
            var    values = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string> ("pseudo", login.Text),
                new KeyValuePair <string, string> ("password", pass.Password),
            };
            var httpClient = new HttpClient(new HttpClientHandler());
            HttpResponseMessage response = await httpClient.PostAsync(url, new FormUrlEncodedContent(values));

            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            if (responseString.Equals(""))
            {
                MessageBox.Show("Mot de Passe incorrect");
            }
            else
            {
                models.User user = JsonConvert.DeserializeObject <models.User>(responseString);
                models.Data.user = user;
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
        }
コード例 #2
0
 public void CheckFormEmailAlredyUsedExceptionTest()
 {
     models.User user = new models.User()
     {
         Nickname = "uniqueNicknames",
         Email    = email
     };
     users.Add(user);
     Assert.ThrowsException <EmailAlredyUsedException>(() => UserFormUtils.CheckForm(name, surname, email, nickname, password, password2, users));
 }
コード例 #3
0
        public static void UserPost(
            string username  = null, // str of the username give my the player
            string email     = null, // str of the user's email address
            string full_name = null, // str of the full name
            string password  = null) // str of the password which will be hashed
        {                            /*
                                      *          This will update a PnP user
                                      */
            if (benChristenson.userPost == null)
            {
                benChristenson.userPost = m_instance.gameObject.AddComponent <behaviors.UserPost>();
                benChristenson.userPost.DestroyOnComplete = benChristensonApiInitialize.is_behavior_destroyed_on_complete();
            }


            if (m_logLevel > 3)
            {
                Debug.Log(Prefix() + "UserPost started");
            }

            benChristenson.userPost.Spawn(username, email, full_name, password,
                                          Callback: new Action <operations.UserPost, HttpResponse> ((operation, response) =>
            {
                try
                {
                    if (response.HasError)
                    {
                        if (m_logLevel > 1)
                        {
                            Debug.LogError(Prefix() + "UserPost failed " + response.Error);
                        }
                    }
                    else
                    {
                        models.User responseData = operation.responseData;        // User dict of the user updated
                        if (m_logLevel > 2)
                        {
                            Debug.Log(Prefix() + "UserPost completed Successfully with " + responseData.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (m_logLevel > 0)
                    {
                        Debug.LogError(Prefix() + "UserPost failed in response with: " + ex.ToString());
                    }
                }
            }));
        }
コード例 #4
0
        public static void UserLoginPost(
            string username,     // str of the username
            string password,     // str of the password
            string email = null) // str of the email as an alternative to username
        {                        /*
                                  *          This will process logging the user in
                                  */
            if (benChristenson.userLoginPost == null)
            {
                benChristenson.userLoginPost = m_instance.gameObject.AddComponent <behaviors.UserLoginPost>();
                benChristenson.userLoginPost.DestroyOnComplete = benChristensonApiInitialize.is_behavior_destroyed_on_complete();
            }


            if (m_logLevel > 3)
            {
                Debug.Log(Prefix() + "UserLoginPost started");
            }

            benChristenson.userLoginPost.Spawn(username, password, email,
                                               Callback: new Action <operations.UserLoginPost, HttpResponse> ((operation, response) =>
            {
                try
                {
                    if (response.HasError)
                    {
                        if (m_logLevel > 1)
                        {
                            Debug.LogError(Prefix() + "UserLoginPost failed " + response.Error);
                        }
                    }
                    else
                    {
                        models.User responseData = operation.responseData;        // User dict
                        if (m_logLevel > 2)
                        {
                            Debug.Log(Prefix() + "UserLoginPost completed Successfully with " + responseData.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (m_logLevel > 0)
                    {
                        Debug.LogError(Prefix() + "UserLoginPost failed in response with: " + ex.ToString());
                    }
                }
            }));
        }
コード例 #5
0
        public static void UserGet()
        {
            if (benChristenson.userGet == null)
            {
                benChristenson.userGet = m_instance.gameObject.AddComponent <behaviors.UserGet>();
                benChristenson.userGet.DestroyOnComplete = benChristensonApiInitialize.is_behavior_destroyed_on_complete();
            }


            if (m_logLevel > 3)
            {
                Debug.Log(Prefix() + "UserGet started");
            }

            benChristenson.userGet.Spawn(
                Callback: new Action <operations.UserGet, HttpResponse> ((operation, response) =>
            {
                try
                {
                    if (response.HasError)
                    {
                        if (m_logLevel > 1)
                        {
                            Debug.LogError(Prefix() + "UserGet failed " + response.Error);
                        }
                    }
                    else
                    {
                        models.User responseData = operation.responseData;        // User dict of the current user
                        if (m_logLevel > 2)
                        {
                            Debug.Log(Prefix() + "UserGet completed Successfully with " + responseData.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (m_logLevel > 0)
                    {
                        Debug.LogError(Prefix() + "UserGet failed in response with: " + ex.ToString());
                    }
                }
            }));
        }
コード例 #6
0
ファイル: UsersController.cs プロジェクト: Ansar3/DatingApp
        public async Task <IActionResult> UpdatedUser(int id, UserForUpdateDto userForUpdateDto)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            models.User user1 = await _repo.GetUser(id);

            var userFromRepo = user1;

            models.User user = _mapper.Map(userForUpdateDto, userFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating user {id} failed on save");
        }
コード例 #7
0
        public async Task <bool> UpdateUser(string user)
        {
            try
            {
                User newUser = new models.User();
                try { newUser = JsonConvert.DeserializeObject <User>(user); }
                catch
                {
                    Debug.WriteLine("ERRR");
                }
                int a = 6;
                a = a + 5;
                db.user.Update(
                    newUser
                    );
                await db.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #8
0
 public AdminPanel(models.User user)
 {
     InitializeComponent();
 }
コード例 #9
0
ファイル: user.cs プロジェクト: christensonb/Seaborn
 private void OnFail(operations.UserPost operation, HttpResponse response)
 {
     responseData = null;
     Status       = ApiBehaviorStatus.FAILURE;
 }
コード例 #10
0
ファイル: user.cs プロジェクト: christensonb/Seaborn
        public models.User responseData;        // User dict of the user updated

        private void OnSuccess(operations.UserPost operation, HttpResponse response)
        {
            responseData = operation.responseData;
            Status       = ApiBehaviorStatus.SUCCESS;
        }
コード例 #11
0
ファイル: UsersResponse.cs プロジェクト: HubblHQ/hubbl-web
 public User(models.User user)
 {
     this.id   = user.id.ToString();
     this.name = user.name;
 }