Beispiel #1
0
        static void CancellaArticolo()
        {
            int idArticolo;

            Console.WriteLine("Inserisci il codice articolo");


            bool success = int.TryParse(Console.ReadLine(), out idArticolo);

            if (success)
            {
                if (Articles.Delete(idArticolo))
                {  // CANCELLO PER ID
                    Console.WriteLine("Articolo cancellato");
                }
                else
                {
                    Console.WriteLine("Articolo non trovato");
                }
            }
            else
            {
                Console.WriteLine("Valore errato");
            }
        }
        //게시판 글 삭제
        public JsonResult delete(string ArticleIDX)
        {
            string   result   = string.Empty;
            Articles articles = new Articles();
            Boolean  check    = articles.Delete(ArticleIDX);

            if (check)
            {
                result = "OK";
            }
            else
            {
                result = "FAIL";
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Index(String operation, Article a)
        {
            switch (operation)
            {
            case "Consulter":
                if (a.Titre == null)
                {
                    ViewBag.Erreur = "Erreur : Vous devez saisir un titre !!!";
                    return(View());
                }
                string titre = a.Titre;
                a = repo.Find(a.Titre);
                if (a == null)
                {
                    ViewBag.Erreur = "L'article n'existe pas";
                    ViewBag.Titre  = titre;
                }
                ViewBag.Article = a;
                break;

            case "Update":
                if (ModelState.IsValid)
                {
                    a.IdContributeur = 1;
                    repo.Update(a);
                }
                break;

            case "Add":
                if (ModelState.IsValid)
                {
                    a.IdContributeur = 1;
                    repo.Add(a);
                }
                break;

            case "Delete":
                repo.Delete(a.Titre);
                break;
            }
            return(View());
        }
Beispiel #4
0
        public JsonResult Delete(int id)
        {
            var jsonSuccessResult = new JsonSuccessResult();

            try
            {
                Articles.Delete(id);
                jsonSuccessResult.Success = true;
            }
            catch (Exception ex)
            {
                jsonSuccessResult.Errors  = new string[] { ex.Message };
                jsonSuccessResult.Success = false;
            }

            return(new JsonResult()
            {
                Data = jsonSuccessResult
            });
        }
Beispiel #5
0
        public ActionResult Index(String operation, Article a)
        {
            switch (operation)
            {
            case "Find":
                if (a.Titre == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                a = repo.Find(a.Titre);
                if (a == null)
                {
                    return(HttpNotFound());
                }
                ViewBag.Article = a;
                break;

            case "Update":
                if (ModelState.IsValid)
                {
                    a.IdContributeur = 1;
                    repo.Update(a);
                }
                break;

            case "Add":
                if (ModelState.IsValid)
                {
                    a.IdContributeur = 1;
                    repo.Add(a);
                }
                break;

            case "Delete":
                repo.Delete(a.Titre);
                break;
            }

            return(View(repo.GetArticles()));
        }
Beispiel #6
0
 /********************************************* Supprimer *********************************************/
 public ActionResult Supprimer(string titre) //Juan Carlos
 {
     if (Request.HttpMethod == "GET")
     {
         Article a = repo.Find(titre);
         if (a == null)
         {
             ViewBag.Erreur = "L'article n'a pas ete supprime";
             return(View("Error"));
         }
         return(View(a));
     }
     else
     {
         if (repo.Delete(titre))
         {
             return(RedirectToAction("Index", new { titre = "" }));
         }
         ViewBag.Erreur = "L'article n'a pas ete supprime";
         return(View("Error"));
     }
 }
Beispiel #7
0
        static void TestaArticoli()
        {
            // avvio il costruttore

            Article myArticle1 = new Article("Face mask", (decimal)12.44);

            Console.WriteLine(myArticle1.List());



            Console.WriteLine(myArticle1.List());
            myArticle1.Update((decimal)12.5, "Face mask", 15, 22);

            Console.WriteLine(myArticle1.List());

            Console.WriteLine("Avvio distruzione oggetto");
            myArticle1.Destroy(1);

            Console.WriteLine(myArticle1.List());
            myArticle1.Stock = 200;
            Console.WriteLine(myArticle1.List());


            //{  // utilizzo di una lista di articoli esterna
            //    List<Article> myArticlelist = new List<Article>()
            //    {
            //        new Article(1, "Face mask",  (decimal)44.5 ),
            //        new Article( 2,"trapano",  (decimal)57.5 )

            //    };

            //    foreach (Article c in myArticlelist)
            //        System.Console.WriteLine(c.List());//scorro e stampo a video il contenuto della lista
            //}

            //Articles myArticles = new Articles();
            //myArticles.Add(myArticle1);
            //Console.WriteLine(myArticles.Count());
            ////----
            //Article myArticle2 = new Article(2, "cacciavite", (decimal)12.44);

            //myArticles.Add(myArticle2);
            ////----
            //Article myArticle3 = new Article(3, "quaderno", (decimal)12.44);
            //myArticles.Add(myArticle3);

            ////----
            //Article myArticle4 = new Article(4, "penna", (decimal)12.44);
            //myArticles.Add(myArticle4);
            ////----
            ///
            //-------------------------------------------

            Articles.Add(myArticle1);
            Console.WriteLine(Articles.Count());
            //----
            Article myArticle2 = new Article("cacciavite", (decimal)12.44);

            Articles.Add(myArticle2);
            //----
            Article myArticle3 = new Article("quaderno", (decimal)12.44);

            Articles.Add(myArticle3);

            //----
            Article myArticle4 = new Article("penna", (decimal)12.44);

            Articles.Add(myArticle4);
            //----
            //--------------------------------------

            Articles.Delete(myArticle2);
            Console.WriteLine(Articles.Count());
            Articles.Delete(myArticle3);

            Articles.List();

            //--
            Article myArticleSearched = Articles.SearchArticle("penna"); //Finishing the ecommerce structure (#6)

            Console.WriteLine("l'id ricercato è " + myArticleSearched.Id_article);

            if (Articles.Delete(myArticleSearched.Id_article))
            {  // CANCELLO PER ID
                Console.WriteLine("Articolo cancellato");
            }
            else
            {
                Console.WriteLine("Articolo non trovato");
            }
        }
Beispiel #8
0
 public ActionResult SupprimerConfirmer(string id)
 {
     Articles.Delete(id);
     return(RedirectToAction("Index", "Home"));
 }