Exemple #1
0
        public async Task <IActionResult> Delete(int id)
        {
            var                 commercants = new CommercantData();
            HttpClient          client      = _api.Initial();
            HttpResponseMessage res         = await client.DeleteAsync($"api/commercants/{id}");

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public async Task <CommercantData> Edit(CommercantData commercants)
        {
            HttpClient client = _api.Initial();

            HttpResponseMessage response = await client.PutAsJsonAsync(
                $"api/commercants/{commercants.CommercantId}", commercants);

            response.EnsureSuccessStatusCode();

            commercants = await response.Content.ReadAsAsync <CommercantData>();

            return(commercants);
        }
Exemple #3
0
        public async Task <IActionResult> Edit(int id)
        {
            var                 commercants = new CommercantData();
            HttpClient          client      = _api.Initial();
            HttpResponseMessage res         = await client.GetAsync($"api/commercants/{id}");

            if (res.IsSuccessStatusCode)
            {
                var result = res.Content.ReadAsStringAsync().Result;
                commercants = JsonConvert.DeserializeObject <CommercantData>(result);
            }
            return(View(commercants));
        }
Exemple #4
0
        public async Task <ActionResult <CommercantData> > Connexion_commercant(CommercantData commercants)
        {
            HttpClient client = _api.Initial();

            //HttpPost
            HttpResponseMessage postTask = await client.GetAsync("api/commercants/LoginClient");

            if (postTask.IsSuccessStatusCode)
            {
                return(View("Connexion_client", commercants));
            }
            else
            {
                //return RedirectToAction("ListArticleUtilisateur", "Articles");
                return(RedirectToAction("ListMarche", "Categories"));
            }
        }
Exemple #5
0
        public IActionResult Inscription_commercant(CommercantData commercants)
        {
            HttpClient client = _api.Initial();

            //HttpPost
            var postTask = client.PostAsJsonAsync <CommercantData>("api/commercants", commercants);

            postTask.Wait();
            var result = postTask.Result;

            if (result.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            //ViewBag.categorieId = new SelectList(db.Categories, "categorieId", "Nom", categories.CategorieId);
            //ViewBag.smsid = new SelectList(db.Sms, "smsid", "smsid", categories.Smsid);
            return(View());
        }