Exemple #1
0
 public ActionResult <double> Commenter(string publicationId, [FromBody] CommentaireSend commentaire)
 {
     try
     {
         var id = Guid.NewGuid().ToString();
         commentaire.Id = id;
         var com = commentaire.Commentaire;
         com.Id = id;
         var CommentaireML = new PredictedModels.PredictedCommentaire(com);
         CommentaireML = CommentaireML.AttribScoreAndTypeOfComment();
         var commentf = CommentaireML;
         var publicationCollection = new PublicationCollection();
         var publication           = publicationCollection.GetItems(p1 => p1.Id == publicationId).FirstOrDefault();
         if (publication == null)
         {
             throw new Exception("Publication not found");
         }
         ((List <CommentaireSend>)(publication.Commentaires)).Add(commentaire);
         var p = publication;
         publicationCollection.UpdateItem(publication.Id, publication);
         return(StatusCode(200, commentaire));
     }
     catch (Exception e)
     {
         return(StatusCode(500, $"Internal Server Error: {e.Message}"));
     }
 }
Exemple #2
0
        public ActionResult <string> Get(int id)
        {
            //return null;
            var comment = new PredictedModels.PredictedCommentaire()
            {
                Value = "Je déteste ce projet"
            };
            var data = comment.AttribScoreAndTypeOfComment();

            return(JsonConvert.SerializeObject(data));
        }
Exemple #3
0
        public static (double, DemandeurIdentite) AttribScoreForOneCandidat(Demandeur demandeur)
        {
            var publicationId          = demandeur.Publications.Select(p => p.Id);
            var PublicationsCollection = new PublicationCollection();
            var publications           = PublicationsCollection.GetItems(p => publicationId.Contains(p.Id)).ToList();
            var like    = 0;
            var ranking = 0.0;

            foreach (var p in publications)
            {
                foreach (var c in p.Commentaires)
                {
                    var predictedCommentaire = new PredictedModels.PredictedCommentaire(c.Commentaire);
                    predictedCommentaire = predictedCommentaire.AttribScoreAndTypeOfComment();
                    ranking += predictedCommentaire.Score;
                }
                like += p.Likes.Where(l => l.Etat == true).Count();
            }
            return(ranking + like, demandeur.Identite);
        }