Esempio n. 1
0
        private void Button_Click_Get1(object sender, RoutedEventArgs e)
        {
            CodeEspecePoissonDTO viewModel = dgPoissons.SelectedItem as CodeEspecePoissonDTO;
            WindowGet1           newwin    = new WindowGet1(viewModel);

            newwin.Show();
        }
 public WindowGet1(CodeEspecePoissonDTO viewModel)
 {
     InitializeComponent();
     tblCode.Text      = viewModel.Code;
     tblNomCommun.Text = viewModel.Nom_Commun;
     tblNomLatin.Text  = viewModel.Nom_Latin;
     tblCodeTaxon.Text = viewModel.Code_Taxon.ToString();
     tblUriTaxon.Text  = viewModel.Uri_Taxon;
     tblStatut.Text    = viewModel.Statut;
 }
        private void Button_Click_Post(object sender, RoutedEventArgs e)
        {
            CodeEspecePoissonDTO mybody = GetNewPoisson();
            APIAccess            myAPI  = new APIAccess();
            HttpResponseMessage  mess   = myAPI.Methode("api/CodeEspecePoisson", "post", mybody);

            if (mess.IsSuccessStatusCode)
            {
                MessageBox.Show("Poisson " + mybody.Nom_Commun + " a été bien ajouté \n Status Code : " + mess.StatusCode);
            }
            else
            {
                MessageBox.Show("L'ajout de " + mybody.Nom_Commun + " a rencontré une erreur : " + mess.StatusCode + " : " + mess.ReasonPhrase);
            }
        }
Esempio n. 4
0
        private void Button_Click_Delete(object sender, RoutedEventArgs e)
        {
            CodeEspecePoissonDTO viewModel = dgPoissons.SelectedItem as CodeEspecePoissonDTO;
            int                 id         = viewModel.Code_Taxon;
            APIAccess           apiAccess  = new APIAccess();
            HttpResponseMessage mess       = apiAccess.Methode("api/CodeEspecePoisson/" + id, "delete", null);

            if (mess.IsSuccessStatusCode)
            {
                MessageBox.Show("Poisson supprimée");
            }
            else
            {
                MessageBox.Show("Suppression rencontre une erreur : ", mess.ReasonPhrase);
            }
        }
Esempio n. 5
0
        public CodeEspecePoissonDTO GetCodeEspecePoissonDTO(int codeTaxon)
        {
            HttpResponseMessage reponse = Methode(GetUri() + "/" + codeTaxon, "get", null);
            string content = reponse.Content.ReadAsStringAsync().Result;

            CodeEspecePoissonDTO poisson = new CodeEspecePoissonDTO();

            if (reponse.IsSuccessStatusCode)
            {
                poisson = JsonConvert.DeserializeObject <CodeEspecePoissonDTO>(content);
            }
            else
            {
                poisson = null;
            }
            return(poisson);
        }
        public CodeEspecePoissonDTO GetNewPoisson()
        {
            CodeEspecePoissonDTO newViewModel = new CodeEspecePoissonDTO(Convert.ToInt32(tblCodeTaxon.Text), tblCode.Text, tblNomCommun.Text, tblNomLatin.Text, tblUriTaxon.Text, tblStatut.Text);

            return(newViewModel);
        }