public ActionResult EditAnnounce(int id)
        {
            Annonce announceToUpdate = announceBL.GetAnnounce(id);

            if (announceToUpdate != null)
            {
                AnnounceVM annonceVM = new AnnounceVM()
                {
                    description   = announceToUpdate.description,
                    estActive     = announceToUpdate.estActive,
                    idAnnonce     = announceToUpdate.idAnnonce,
                    idCategorie   = announceToUpdate.idCategorie,
                    idUtilisateur = announceToUpdate.idUtilisateur,
                    nbSlot        = announceToUpdate.nbSlot,
                    nbSlotUtilise = announceToUpdate.nbSlotUtilise,
                    titre         = announceToUpdate.titre
                };

                annonceVM.lesCategories = categoryBL.GetAllCategories();
                return(View(annonceVM));
            }
            else
            {
                return(RedirectToAction("GetAllAnnounces", "Announce"));
            }
        }
        public ActionResult AddAnnounce()
        {
            AnnounceVM announceVM = new AnnounceVM();

            announceVM.lesCategories = categoryBL.GetAllCategories();
            return(View(announceVM));
        }
 public ActionResult EditAnnounce(AnnounceVM pAnnounce)
 {
     try
     {
         Annonce newAnnounce = new Annonce()
         {
             description   = pAnnounce.description,
             estActive     = pAnnounce.estActive,
             idAnnonce     = Convert.ToInt16(pAnnounce.idAnnonce),
             idCategorie   = pAnnounce.idCategorie,
             idUtilisateur = pAnnounce.idUtilisateur,
             nbSlot        = pAnnounce.nbSlot,
             nbSlotUtilise = pAnnounce.nbSlotUtilise,
             titre         = pAnnounce.titre
         };
         if (announceBL.EditAnnounce(newAnnounce))
         {
             return(RedirectToAction("GetAllAnnounces", "Announce"));
         }
         else
         {
             return(View(pAnnounce));
         }
     }
     catch (Exception)
     {
         return(View(pAnnounce));
     }
 }
        public ActionResult AddAnnounce(AnnounceVM pAnnounce)
        {
            try
            {
                if (Request.Cookies["Hackathon"] != null)
                {
                    pAnnounce.idUtilisateur = Convert.ToInt32(Request.Cookies["Hackathon"]["IdUser"]);
                    Annonce newAnnounce = new Annonce()
                    {
                        description   = pAnnounce.description,
                        estActive     = true,
                        idAnnonce     = Convert.ToInt16(pAnnounce.idAnnonce),
                        idCategorie   = pAnnounce.idCategorie,
                        idUtilisateur = pAnnounce.idUtilisateur,
                        nbSlot        = pAnnounce.nbSlot,
                        nbSlotUtilise = 1,
                        titre         = pAnnounce.titre
                    };


                    if (announceBL.AddAnnounce(newAnnounce))
                    {
                        return(RedirectToAction("GetAllAnnounces", "Announce"));
                    }
                    else
                    {
                        return(View(pAnnounce));
                    }
                }
                else
                {
                    return(View(pAnnounce));
                }
            }
            catch (Exception)
            {
                return(View(pAnnounce));
            }
        }