Exemplo n.º 1
0
        private void EditUser(Utilisateur user)
        {
            var utilisateur = new UtilisateurEdit(user, false);

            utilisateur.ShowDialog();
            RefreshDataSource();
        }
Exemplo n.º 2
0
        private void CreateUser()
        {
            var utilisater = new UtilisateurEdit(new Utilisateur(), true);

            utilisater.ShowDialog();
            RefreshDataSource();
        }
Exemplo n.º 3
0
        public override bool Update()
        {
            HttpResponseMessage response   = null;
            HttpResponseMessage response2  = null;
            UtilisateurEdit     windowEdit = new UtilisateurEdit(this);

            windowEdit.ShowDialog();

            if (windowEdit.DialogResult.HasValue && windowEdit.DialogResult.Value == true)
            {
                try
                {
                    using (var client = new HttpClient())
                    {
                        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Database.MegaCastingAPIEntities.token);

                        string json = JsonConvert.SerializeObject(this, Formatting.Indented);

                        var buffer      = System.Text.Encoding.UTF8.GetBytes(json);
                        var byteContent = new ByteArrayContent(buffer);

                        byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                        if (this.UTI_MDP == "")
                        {
                            response = client.PutAsync(Database.MegeCastingDatabase.Current.T_S_UTILISATEUR_UTI.Path + "/" + this.UTI_ID, byteContent).Result;

                            if (response.IsSuccessStatusCode)
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            response2 = client.PutAsync(Database.MegeCastingDatabase.Current.T_S_UTILISATEUR_UTI.Path + "/" + this.UTI_ID, byteContent).Result;
                            response  = client.PutAsync(Database.MegeCastingDatabase.Current.T_S_UTILISATEUR_UTI.Path + "/mdp/" + this.UTI_ID, byteContent).Result;
                            if (response.IsSuccessStatusCode && response2.IsSuccessStatusCode)
                            {
                                return(true);
                            }
                        }
                    }

                    return(false);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }