Ejemplo n.º 1
0
 public PredictedCommentaire(Commentaire commentaire) : base()
 {
     this.Value     = commentaire.Value;
     this.Id        = commentaire.Id;
     this.Date      = commentaire.Date;
     this.Sentiment = commentaire.Sentiment;
 }
        public async Task <IHttpActionResult> PutCommentaire(int id, Commentaire commentaire)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != commentaire.IdCommentaire)
            {
                return(BadRequest());
            }

            db.Entry(commentaire).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CommentaireExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        /* Selectionner un commentaire de la base de données à partir de son id
         * @param id : id du commentaire à selectionner
         */
        public static Commentaire selectCommentaireById(int id)
        {
            try
            {
                Commentaire retour = new Commentaire();

                //connection à la base de données
                MySqlCommand cmd = new MySqlCommand(Bdd.selectCommentaireById, Bdd.connexion());

                //ajout des parametres
                cmd.Parameters.AddWithValue("id", id);

                //Execute la commande
                MySqlDataReader msdr = cmd.ExecuteReader();
                while (msdr.Read())
                {
                    retour = new Commentaire(
                        Int32.Parse(msdr["com_id"].ToString()),
                        msdr["com_com"].ToString());
                }
                msdr.Dispose();
                Bdd.deconnexion();
                return(retour);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("ERREUR BDD : selectCommentaireById");
                Bdd.deconnexion();
                return(null);
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nom,Email,Texte,DateCommentaire")] Commentaire commentaire)
        {
            if (id != commentaire.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(commentaire);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentaireExists(commentaire.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(commentaire));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Insertion d'un commentaire
        /// </summary>
        /// <returns>The commentaire.</returns>
        /// <param name="objet">Objet.</param>
        public int insertCommentaire(Commentaire objet)
        {
            int idInsere = -1;

            try
            {
                string requete = "insert into tblCommentaire (NomUtilisateur,Message,DateCreation,idActualite,idDocument) ";
                requete = requete + " values ( '" + objet.Utilisateur.Replace("'", "''") + "'";
                requete = requete + " , '" + objet.Message.Replace("'", "''") + "'";
                requete = requete + " , '" + Commons.Utils.getFormatStringPourDateMySQL(objet.DateCreation) + "'";
                requete = requete + " , " + (objet.idActualite == null ? "NULL" : objet.idActualite.ToString());
                requete = requete + " , " + (objet.idDocument == null ? "NULL" : objet.idDocument.ToString());
                requete = requete + " )";

                bool result = db.executerRequete(requete);
                // On récupère ensuite le dernier id inséré en base en cas de succès de l'insertion.
                if (result)
                {
                    idInsere = db.getLastInsertID();
                }
            }
            catch (Exception e)
            {
                Commons.Logger.genererErreur(typeof(CommentaireDAL), e.ToString());
            }
            return(idInsere);
        }
Ejemplo n.º 6
0
        /* Selectionner l'ensemble des commentaires de la base de données
         */
        public static List <Commentaire> selectCommentaire()
        {
            try
            {
                List <Commentaire> retour = new List <Commentaire>();

                //connection à la base de données
                MySqlCommand cmd = new MySqlCommand(Bdd.selectCommentaire, Bdd.connexion());

                //Execute la commande
                MySqlDataReader msdr = cmd.ExecuteReader();
                Commentaire     commentaire;
                while (msdr.Read())
                {
                    commentaire = new Commentaire(
                        Int32.Parse(msdr["com_id"].ToString()),
                        msdr["com_com"].ToString());
                    retour.Add(commentaire);
                }
                msdr.Dispose();
                Bdd.deconnexion();
                return(retour);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("ERREUR BDD : selectCommentaire");
                Bdd.deconnexion();
                return(null);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Méthode pour rechercher un commentaire par son index.
        /// </summary>
        /// <param name="id">L'index à chercher.</param>
        /// <returns>Le commentaire ayant l'index envoyé.</returns>
        public Commentaire Find(int id)
        {
            Commentaire commentaire = FactoryCommentaire.Commentaires.FirstOrDefault(c => c.IdCommentaire == id);

            commentaire.Titre = FactoryTitre.Titres.FirstOrDefault(t => t.IdTitre == commentaire.IdTitre);
            return(commentaire);
        }
Ejemplo n.º 8
0
        public void DeleteComment(int commentId)
        {
            Commentaire commentaire = GetComment(commentId);

            _fabContext.Commentaire.Remove(commentaire);
            _fabContext.SaveChanges();
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Méthode pour ajouter un nouveau commentaire.
 /// </summary>
 /// <param name="commentaire">Le commentaire à ajouter.</param>
 public void Add(Commentaire commentaire)
 {
     commentaire.IdCommentaire = FactoryCommentaire.Commentaires.Max(c => c.IdCommentaire) + 1;
     commentaire.Titre         = FactoryTitre.Titres.FirstOrDefault(t => t.IdTitre == commentaire.IdTitre);
     FactoryTitre.Titres.First(t => t.IdTitre == commentaire.IdTitre).Commentaires.Add(commentaire);
     FactoryCommentaire.Commentaires.Add(commentaire);
 }
Ejemplo n.º 10
0
        public bool Update(Commentaire c)
        {
            var entry = db.Entry(c);

            entry.State = System.Data.Entity.EntityState.Modified;
            return(db.SaveChanges() >= 0);
        }
        public async Task TestReadDataBaseEnvies()
        {
            var databaseService = new DataBaseService();

            var FireBaseClient = databaseService.GetFirebaseClient();

            var userGet = await FireBaseClient.Child("users").Child("Bérengère").OnceAsync <User>();

            var user = userGet.FirstOrDefault()?.Object;

            var envie = new Envie("sapin de noel", "celui que je veux c'est Cdiscount a 35€ avec plein de fleurs", user);

            var temp = await FireBaseClient.Child("envies").PostAsync(envie);

            var key = temp.Key;

            var comment = new Commentaire("commentaire1");

            envie = envie.SetCommentaire(comment);

            var tempEnvie = await FireBaseClient.Child("envies").Child(key).PostAsync(comment);

            var envieDB = await FireBaseClient.Child("envies").Child(key).OnceSingleAsync <Envie>();

            Check.That(envie).HasFieldsWithSameValues(envieDB);
        }
        public ActionResult CreerCommentairePost(string Utilisateur, string Message, int ActualiteId, string couleurCommentaire)
        {
            Actualite model = new Actualite();

            try
            {
                // On commence par créer l'entité commentaire
                Commentaire NouveauCommentaire = new Commentaire();
                NouveauCommentaire.idActualite  = ActualiteId;
                NouveauCommentaire.Message      = Message;
                NouveauCommentaire.Utilisateur  = Utilisateur;
                NouveauCommentaire.DateCreation = DateTime.Now;

                using (CommentaireDAL db = new CommentaireDAL())
                {
                    int idCommentaire = db.insertCommentaire(NouveauCommentaire);
                }
                using (ActualiteDAL dbActu = new ActualiteDAL())
                {
                    model = dbActu.getActualiteById(ActualiteId, couleurCommentaire);
                }
                model.styleCommentairesActualite = "";
                System.Web.HttpContext.Current.Session[Commons.Const.sessionName_NomUtilisateurCommentaire] = Utilisateur;
            }
            catch (Exception e)
            {
                Commons.Logger.genererErreur(typeof(CommentaireController), e.ToString());
                //	return RedirectToAction("AfficherErreur", "Error", new { message = e.Message });
            }

            return(PartialView("~/Views/Commentaire/Commentaires.cshtml", model));
        }
        public async Task <ActionResult <CommentaireDto> > CreateCommentaire([FromBody] CommentaireDto commentaireDto)
        {
            try
            {
                var commentaire = new Commentaire
                {
                    CommentaireId = commentaireDto.CommentaireId,
                    Description   = commentaireDto.Description,
                    Date          = commentaireDto.Date,
                    EvenementId   = commentaireDto.EvenementId
                };

                _context.Commentaire.Add(commentaire);
                await _context.SaveChangesAsync();

                return(CreatedAtAction(
                           nameof(GetCommentaireById),
                           new { CommentaireId = commentaire.CommentaireId },
                           CommentaireToDTO(commentaire)));
            }
            catch (Exception e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new Error {
                    Message = e.Message
                }));
            }
        }
Ejemplo n.º 14
0
        public IActionResult Commentaire(TitreViewModel titreViewModel)
        {
            Titre          titre             = _titreRepository.Find(titreViewModel.IdTitre);
            TitreViewModel newTitreViewModel = new TitreViewModel
            {
                Titre   = titre,
                IdTitre = titre.IdTitre
            };

            if (ModelState.IsValid)
            {
                Commentaire commentaire = new Commentaire
                {
                    Auteur       = titreViewModel.NewCommentaire.Auteur,
                    Contenu      = titreViewModel.NewCommentaire.Contenu,
                    DateCreation = DateTime.Now,
                    IdTitre      = newTitreViewModel.IdTitre,
                    Titre        = _titreRepository.Find(newTitreViewModel.IdTitre)
                };
                _commentaireRepository.Add(commentaire);
                return(RedirectToAction(nameof(TitreController.Index), "Titre", new { id = titreViewModel.IdTitre }));
            }
            else
            {
                return(RedirectToAction(nameof(TitreController.Index), "Titre", new { id = titreViewModel.IdTitre }));
            }
        }
        public void saveCommentaire(Commentaire commentaire)
        {
            String sqlStoring = "INSERT INTO CommentairesTable ( isbn , id_abonne, content ) VALUES ('" + commentaire.Isbn + "','" + commentaire.Id_abonne + "','" + commentaire.Content + "');";

            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlStoring, conn);
            cmd.ExecuteNonQuery();
        }
        public async Task <ActionResult <Commentaire> > PostAsync(Commentaire entity)
        {
            var k      = new AddGeneric <Commentaire>(entity);
            var result = await _mediator.Send(k);

            return(Ok(result));
        }
        public async Task <ActionResult <Commentaire> > Put([FromBody] Commentaire etu)
        {
            var k      = new PutGeneric <Commentaire>(etu);
            var result = await _mediator.Send(k);

            return(Ok(result));
        }
Ejemplo n.º 18
0
        public IActionResult AddComment(string titre, string text, string typePubli, int idPubli)
        {
            ViewBag.NbreVisitUnique = GetVisitIP();
            ViewBag.NbrePagesVues   = GetPageVues();
            UserConnect(ViewBag);

            Commentaire c = new Commentaire
            {
                Titre     = titre,
                Text      = text,
                TypePubli = typePubli,
                IdPubli   = idPubli,
                IdMembre  = Convert.ToInt32(ViewBag.Id),
                Date      = DateTime.Now
            };

            c.AddComment();

            if (typePubli == "article")
            {
                return(RedirectToRoute(new { controller = "Home", action = "ViewArticle", id = idPubli }));
            }

            else
            {
                return(RedirectToRoute(new { controller = "Home", action = "ViewArticle", id = idPubli }));
            }
        }
Ejemplo n.º 19
0
        public async Task <ActionResult <Commentaire> > PostCommentaire(Commentaire commentaire)
        {
            _context.Commentaires.Add(commentaire);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCommentaire", new { id = commentaire.CommentaireId }, commentaire));
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> PutCommentaire(long id, Commentaire commentaire)
        {
            if (id != commentaire.CommentaireId)
            {
                return(BadRequest());
            }

            _context.Entry(commentaire).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CommentaireExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 21
0
        public Commentaire GetCommsById(int id)
        {
            var         c     = _context.commentaire.Find(id);
            Commentaire comms = c;

            return(comms);
        }
        /// <summary>
        /// Récupère la liste des commentaires sur la liste d'une personne pour un événement donné
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="personneListe"></param>
        /// <returns></returns>
        public List <Commentaire> chargerCommentaires(Evenement evt, Personne personneListe)
        {
            Commentaires comm = new Commentaires();

            List <Commentaire> listeRetour = new List <Commentaire>();

            DataTable comments = new DataTable();

            comments = comm.getCommentairesByPersonneListe(personneListe.id_personne, evt.id_evenement);

            if (comments != null)
            {
                for (int i = 0; i < comments.Rows.Count; i++)
                {
                    Commentaire unComm = new Commentaire();
                    unComm.commentaire   = StringUtils.replaceSautDeLignePourHTML(comments.Rows[i].ItemArray.GetValue(0).ToString());
                    unComm.id_auteur     = int.Parse(comments.Rows[i].ItemArray.GetValue(1).ToString());
                    unComm.ecrit_par     = comments.Rows[i].ItemArray.GetValue(2).ToString();
                    unComm.date_creation = DateTime.Parse(comments.Rows[i].ItemArray.GetValue(3).ToString());
                    if (comments.Rows[i].ItemArray.GetValue(4) != null && "" != comments.Rows[i].ItemArray.GetValue(4).ToString())
                    {
                        unComm.date_modification = DateTime.Parse(comments.Rows[i].ItemArray.GetValue(4).ToString());
                    }
                    unComm.deleted = Boolean.Parse(comments.Rows[i].ItemArray.GetValue(5).ToString());;

                    listeRetour.Add(unComm);
                }
            }

            return(listeRetour);
        }
Ejemplo n.º 23
0
        public IActionResult DeleteComment([FromBody] Commentaire commentaire)
        {
            var entity = this._context.commentaires.FirstOrDefault(item => item.CommentaireId == commentaire.CommentaireId);

            this._context.commentaires.Remove(entity);
            this._context.SaveChanges();
            return(Ok());
        }
Ejemplo n.º 24
0
 public ActionResult Edit(Commentaire commentaire)
 {
     using (IDal dal = new Dal())
     {
         dal.ModifierCommentaire(commentaire.Id, commentaire.Description);
         return(RedirectToAction("Index"));
     }
 }
        public Commentaire FindCommentById(int ID)
        {
            Commentaire item = (from c in this.Comments
                                where c.CommentaireID == ID
                                select c).First();

            return(item);
        }
 /// <summary>
 /// Supprime un commentaire présent dans le set de données
 /// </summary>
 /// <param name="commentaire">Commentaire à supprimer</param>
 void ICommentaireRepository.Delete(Commentaire commentaire)
 {
     // Si le commentaire existe dans le set, suppression
     if (StaticFactory.Commentaires.Contains(commentaire))
     {
         StaticFactory.Commentaires.Remove(commentaire);
     }
 }
Ejemplo n.º 27
0
        public async Task <Commentaire> AddCommentaire(Commentaire commentaire)
        {
            var result = await _context.Commentaires.AddAsync(commentaire);

            await _context.SaveChangesAsync();

            return(result.Entity);
        }
Ejemplo n.º 28
0
        public PartialViewResult _Create(int PhotoId)
        {
            Commentaire newComment = new Commentaire();

            newComment.PhotoID = PhotoId;
            ViewBag.PhotoID    = PhotoId;
            return(PartialView("_CreateAComment"));
        }
Ejemplo n.º 29
0
        public ActionResult DeleteConfirmed(int id)
        {
            Commentaire commentaire = context.FindCommentById(id);

            context.Delete <Commentaire>(commentaire);
            context.SaveChanges();
            return(RedirectToAction("Display", "Photo", new { id = commentaire.PhotoID }));
        }
 private static CommentaireDto CommentaireToDTO(Commentaire commentaire) => new CommentaireDto
 {
     CommentaireId = commentaire.CommentaireId,
     Description   = commentaire.Description,
     Date          = commentaire.Date,
     EvenementId   = commentaire.EvenementId,
     Evenement     = commentaire.Evenement
 };