Exemplo n.º 1
0
        /// <summary>
        /// Récupére l'entité désignée par l'id en paramétre.
        /// </summary>
        /// <param name="id">Id de l'entité</param>
        /// <returns>Message de retour avec l'entité</returns>
        public async Task <DTO.Comment> GetById(long id)
        {
            ENT.Comment comment = await CommentDomain.Get(id);

            DTO.Comment dtoComment = null;
            if (comment != null)
            {
                dtoComment = Mapper.Map <ENT.Comment, DTO.Comment>(comment);
            }

            return(dtoComment);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Récupére toutes les entités DTO existantes.
        /// </summary>
        /// <returns>Message de retour avec la liste en json</returns>
        public async Task <IEnumerable <DTO.Comment> > GetAll()
        {
            IEnumerable <ENT.Comment> comments = await CommentDomain.Get();

            IEnumerable <DTO.Comment> dtoComments = null;

            if (comments != null)
            {
                dtoComments = Mapper.Map <IEnumerable <ENT.Comment>, IEnumerable <DTO.Comment> >(comments);
            }
            else
            {
                dtoComments = new List <DTO.Comment>();
            }

            return(dtoComments);
        }