Exemplo n.º 1
0
        public ActionResult Create(SaleDepartment ev)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://*****:*****@gmail.com";

            String subject = "Product Dans sale deaptement ";

            String      body = "Produit ajouter";
            MailMessage mm   = new MailMessage();

            mm.To.Add(to);
            mm.Subject    = subject;
            mm.Body       = body;
            mm.From       = new MailAddress("*****@*****.**");
            mm.IsBodyHtml = false;
            SmtpClient stmp = new SmtpClient("smtp.gmail.com");

            stmp.Port = 587;
            stmp.UseDefaultCredentials = true;
            stmp.EnableSsl             = true;
            stmp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "Nesrinetry123");
            stmp.Send(mm);
            ViewBag.message = "Good job";
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Edit(SaleDepartment c)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8081");

                //HTTP POST
                var putTask = client.PutAsJsonAsync <SaleDepartment>("/SpringMVC/servlet/advertisement/update-advertisement/", c);
                putTask.Wait();

                var result = putTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(c));
        }
Exemplo n.º 3
0
        public ActionResult Edit(long idSale)
        {
            SaleDepartment c = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8081");
                //HTTP GET
                var responseTask = client.GetAsync("/SpringMVC/servlet/advertisement/detail-advertisement/" + idSale.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <SaleDepartment>();
                    readTask.Wait();

                    c = readTask.Result;
                }
            }

            return(View(c));
        }